Tweaks on account display name
This commit is contained in:
parent
7011a2d231
commit
0f797714f1
|
@ -749,10 +749,10 @@ class WC_Customer extends WC_Legacy_Customer {
|
|||
* Set customer's display name.
|
||||
*
|
||||
* @since 3.1.0
|
||||
* @param string $display_name
|
||||
* @throws WC_Data_Exception
|
||||
* @param string $display_name Display name.
|
||||
*/
|
||||
public function set_display_name( $display_name ) {
|
||||
/* translators: 1: first name 2: last name */
|
||||
$this->set_prop( 'display_name', is_email( $display_name ) ? sprintf( __( '%1$s %2$s', 'display name', 'woocommerce' ), $this->get_first_name(), $this->get_last_name() ) : $display_name );
|
||||
}
|
||||
|
||||
|
|
|
@ -188,11 +188,6 @@ class WC_Form_Handler {
|
|||
return;
|
||||
}
|
||||
|
||||
$current_user = get_user_by( 'id', $user_id );
|
||||
$current_first_name = $current_user->first_name;
|
||||
$current_last_name = $current_user->last_name;
|
||||
$current_email = $current_user->user_email;
|
||||
|
||||
$account_first_name = ! empty( $_POST['account_first_name'] ) ? wc_clean( $_POST['account_first_name'] ): '';
|
||||
$account_last_name = ! empty( $_POST['account_last_name'] ) ? wc_clean( $_POST['account_last_name'] ) : '';
|
||||
$account_display_name = ! empty( $_POST['account_display_name'] ) ? wc_clean( $_POST['account_display_name'] ) : '';
|
||||
|
@ -202,12 +197,20 @@ class WC_Form_Handler {
|
|||
$pass2 = ! empty( $_POST['password_2'] ) ? $_POST['password_2'] : '';
|
||||
$save_pass = true;
|
||||
|
||||
// Current user data.
|
||||
$current_user = get_user_by( 'id', $user_id );
|
||||
$current_first_name = $current_user->first_name;
|
||||
$current_last_name = $current_user->last_name;
|
||||
$current_email = $current_user->user_email;
|
||||
|
||||
// New user data.
|
||||
$user = new stdClass();
|
||||
$user->ID = $user_id;
|
||||
$user->first_name = $account_first_name;
|
||||
$user->last_name = $account_last_name;
|
||||
$user->display_name = $account_display_name;
|
||||
|
||||
// Prevent display name to be changed to email
|
||||
// Prevent display name to be changed to email.
|
||||
if ( is_email( $account_display_name ) ) {
|
||||
wc_add_notice( __( 'Display name cannot be changed to email address due to privacy concern.', 'woocommerce' ), 'error' );
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue