## Change user’s display name programmatically

Question

I’d like to change a user’s display name using this code snippet in my theme’s functions.php file:

$user_id = 672;$display_name= 'Les Yeux';

$user_id = wp_update_user( array( 'ID' =>$user_id, 'display_name' => \$display_name ) );


This is adapted from this topic in the codex: https://codex.wordpress.org/Function_Reference/wp_update_user

But I can’t get it to work. It didn’t change anything. Did I miss something?

0
7 years 2015-12-12T09:19:54-05:00 0 Answers 98 views 0