Custom field content on user account tab cleared when password is changed
-
Hi UM-Support Team,
I have custom fields on the user account tab.
I added these fields using these lines in functions.php:
/**
* Add extra fields to user account tab
*/function showUMExtraFields()
{
$id = um_user(‘ID’);
$output = ”;
$names = array(‘salutation’, ‘first_name’, ‘last_name’, ‘company’, ‘job’);$fields = array();
foreach ($names as $name)
$fields[$name] = UM()->builtin()->get_specific_field($name);
$fields = apply_filters(‘um_account_secure_fields’, $fields, $id);
foreach ($fields as $key => $data)
$output .= UM()->fields()->edit_field($key, $data);
echo $output;
}add_action(‘um_after_account_general’, ‘showUMExtraFields’, 100);
/**
* Get content for extra fields in user account tab
*/
function getUMFormData()
{
$id = um_user(‘ID’);
$names = array(‘salutation’, ‘first_name’, ‘last_name’, ‘company’, ‘job’);foreach ($names as $name)
update_user_meta($id, $name, $_POST[$name]);
}
add_action(‘um_account_pre_update_profile’, ‘getUMFormData’, 100);`The fields are updated when a user updates his profile. So that seems to be working. Only when a user changes his password, all these additional fields are deleted while email and username remain unchanged. Somehow the password change process deletes all entries in custom fields.
I tried getUMFormData with other hooks like um_after_password_reset_fields, etc. but couldn’t manage to get it right.
Can you pls point me in the right direction to solve this riddle?
Thanks for your support.
Hagbard
- The topic ‘Custom field content on user account tab cleared when password is changed’ is closed to new replies.