I'm building user profile page where users could update their profile on the front-end. User profile is extended with a few custom fields, like 'Twitter', 'Facebook' and 'City'.
The following code successfully updates all user details except the dCity
:
$user_fields = array(
'ID' => $current_user->ID,
'nickname' => esc_attr($_POST['nickname']),
'first_name' => esc_attr($_POST['first_name']),
'last_name' => esc_attr($_POST['last_name']),
'display_name' => esc_attr($_POST['display_name']),
'user_email' => esc_attr($_POST['email']),
'user_url' => esc_attr($_POST['url']),
'twitter' => esc_attr($_POST['twitter']),
'facebook' => esc_attr($_POST['facebook']),
'description' => esc_attr($_POST['description']),
'dCity' => esc_attr($_POST['dCity'])
);
wp_update_user($user_fields) ;
I've tried to use update_user_meta
to update dCity
and it worked:
$user_fields = array(
'ID' => $current_user->ID,
'nickname' => esc_attr($_POST['nickname']),
'first_name' => esc_attr($_POST['first_name']),
'last_name' => esc_attr($_POST['last_name']),
'display_name' => esc_attr($_POST['display_name']),
'user_email' => esc_attr($_POST['email']),
'user_url' => esc_attr($_POST['url']),
'twitter' => esc_attr($_POST['twitter']),
'facebook' => esc_attr($_POST['facebook']),
'description' => esc_attr($_POST['description'])
);
wp_update_user($user_fields);
update_user_meta( $current_user->ID, 'dCity', $_POST['dCity'] );
So problem solved, but I'm wondering why wp_update_user
doesn't update all records? Am I doing something wrong?
In advance, thank you.