/* ---------------------------------------------- */
/* Default Display Name as First Name Last Name
/* ---------------------------------------------- */
/**
* New user registrations should have display_name set to 'firstname lastname'
* Best used on 'user_register'
* @param string $name
* @return $name
* @uses pre_user_display_name()\
*/
add_filter('pre_user_display_name', 'default_display_name');
function default_display_name($name) {
if ( isset( $_POST['billing_first_name'] ) ) {
$firstname = sanitize_text_field( $_POST['billing_first_name'] );
}
if ( isset( $_POST['billing_last_name'] ) ) {
$lastname = sanitize_text_field( $_POST['billing_last_name'] );
}
$name = $firstname . ' ' . $lastname;
return $name;
}