Hidden Profile Fields data cleared
-
If you have a field set to not show in a user profile, when the user updates their profile, the field data will be cleared out.
The ‘simplr_reg_profile_save_fields’ function in ‘simplr_form_functions.php’ is not checking to see if a field is visible before trying to update it.
My code below adds a check to see if is set to be ‘show in profile’. Note this will also mean admins can not update this hidden field. An additional check to see if admin could be added if you want admins to be able to update it.
function simplr_reg_profile_save_fields($user_id ) { $custom = new SREG_Fields(); $data = $_POST; $fields = $custom->fields->custom; foreach($fields as $field): if(@$field['show_in_profile'] != 'no') { //added this line to not clear or save data if set to hide on profile page if(!in_array($field['key'] , simplr_get_excluded_profile_fields() )) { if($field['type'] == 'date') { $dy = $data[$field['key'].'-dy']; $mo = $data[$field['key'].'-mo']; $yr = $data[$field['key'].'-yr']; $dateinput = implode('-', array($yr,$mo,$dy)); update_user_meta($user_id,$field['key'],$dateinput); } else { update_user_meta($user_id, $field['key'], $data[$field['key']]); } } } //added this line to not clear or save data if set to hide on profile page endforeach; }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘Hidden Profile Fields data cleared’ is closed to new replies.