Wordpress - How can i force Display names to be the same as Usernames?
You can use the wp_pre_insert_user_data
filter.
function wpse_filter_user_data( $data, $update, $id) {
if( isset( $data[ 'user_login' ] ) ) {
$data[ 'display_name' ] = $data[ 'user_login' ];
return $data;
}
$user = get_user_by( 'email', $data[ 'user_email' ] );
$data[ 'display_name' ] = $user->user_login;
return $data;
}
add_filter( 'wp_pre_insert_user_data', 'wpse_filter_user_data', 10, 3 );
You'll probably want to use Javascript and/or CSS to hide the field too for a better user experience.
$( '.user-display-name-wrap' ).remove();
.user-display-name-wrap {
display:none;
}