Set display name from nickname with register process

Question

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?

0
, X9DESIGN 10 months 0 Answers 52 views 0

Leave an answer