Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
wordpress set display name based on first name & last name
add_filter( 'pre_user_display_name', 'default_display_name' );
function default_display_name( $name ) {
if ( isset( $_POST['display_name'] ) )
return sanitize_text_field( $_POST['display_name'] );
if ( isset( $_POST['first_name'] ) ) {
$name = sanitize_text_field( $_POST['first_name'] );
if ( isset( $_POST['last_name'] ) ) {
$name .= ' ' . sanitize_text_field( $_POST['last_name'] );
}
}
return $name;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.