Development > Development

How to register a field in the user profile?

(1/1)

Xefiron:
Inside user-profile.php I have added the following code:


--- Code: ---<?php if(osc_user_type() == '0') { ?>
  <div class="row">
    <label for="new_field"><span><?php _e('New field', 'stela'); ?></span><span class="req">*</span></label>
    <div class="input-box"><i class="fa fa-address-card-o"></i><?php CustomForm::newfield_text_register(osc_user()); ?></div>
  </div>

  <div class="row">
    <label for="user_type"><?php _e('User type', 'stela'); ?></label>
    <div class="input-box"><i class="fa fa-industry"></i><?php UserForm::is_company_select(osc_user()); ?></div>
  </div>
<?php } ?>
--- End code ---

This is the code of the newfield_text_register() function:


--- Code: ---static public function newfield_text_register($user = null) {
  if( Session::newInstance()->_getForm('newfield') != '' ) {
    $user['s_newfield'] = Session::newInstance()->_getForm('newfield');
  }
  parent::generic_input_text("newfield", isset($user['s_newfield'])? $user['s_newfield'] : '', null, false);
}
--- End code ---

Finally, inside the UserActions.php, at the end of prepareData() function i set this code:


--- Code: ---if($input['b_company'] == 1) {
  $input['s_newfield'] = Params::getParam('newfield');
}
--- End code ---

What I'm looking for is that when the user is of type 0 and select to be type 1, the new field will appear, and he will have to complete it, after that that value of the new field will be registered in the database, but what happens is that only when the selection of the user type does not change (that is, when it is still 0) if the changes made in the other fields are changed and saved, but when selecting type 1 the new field appears, but its value is not saved changes made in the other fields. Any idea what can be treated?

Navigation

[0] Message Index

Go to full version