Why can’t I update username through WordPress API?


I’m just wondering about usernames… Why isn’t is possible to change this through WordPress API? (I understand why a user in the admin dashboard can’t change username(s) but that isn’t really same thing!?)

Code below does just ignore the user_login – setting.

$pupil_obj= get_post($postid_pupil);

$user_login = $pupil_obj->post_name;
$user_nicename = $pupil_obj->post_name;

$user_args = array(
    'ID'            =>  $current_user->ID,
    'user_email'    =>  $email,
    'user_login'    =>  $user_login,
    'user_nicename' =>  $user_nicename                    
wp_update_user( $user_args ) ;

I could update the username to the database directly through $wpdb. This makes no sense to me. Can someone explain?

, bestprogrammerintheworld 3 years 2020-06-07T02:11:49-05:00 0 Answers 92 views 0

Leave an answer