Set display name from nickname with register process


It is possible set display name from entered string into nickname registration field? I trying do this with simple hook, but after all it is not work.

function set_default_display_name( $user_id ) {
  $user = get_userdata( $user_id );
  $name = $user->nickname;
  $args = array(
    'ID' => $user_id,
    'display_name' => $name
  wp_update_user( $args );
add_action( 'user_register', 'set_default_display_name' );

By default, immediately after registration, display name was set from WP username (login) not nickname. Can sombody help me to set a display name from nickname?

, X9DESIGN 4 years 2020-02-17T08:38:25-05:00 0 Answers 61 views 0

Leave an answer