Make WordPress Core

Ticket #41672: 41672.diff

File 41672.diff, 1.6 KB (added by sconzof, 7 years ago)
  • src/wp-includes/user.php

     
    14741474                return new WP_Error( 'user_login_too_long', __( 'Username may not be longer than 60 characters.' ) );
    14751475        }
    14761476
     1477        $raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email'];
     1478
     1479        /**
     1480         * Filters a user's email before the user is created or updated.
     1481         *
     1482         * @since 2.0.3
     1483         *
     1484         * @param string $raw_user_email The user's email.
     1485         */
     1486        $user_email = apply_filters( 'pre_user_email', $raw_user_email );
     1487
    14771488        if ( ! $update && username_exists( $user_login ) ) {
    1478                 return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) );
     1489                if ( email_exists( $user_email ) ) {
     1490                        return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) );
     1491                } else {
     1492                        return new WP_Error( 'existing_user_login', __( 'Sorry, that username already exists!' ) );
     1493                }
    14791494        }
    14801495
    14811496        /**
     
    15291544         */
    15301545        $user_url = apply_filters( 'pre_user_url', $raw_user_url );
    15311546
    1532         $raw_user_email = empty( $userdata['user_email'] ) ? '' : $userdata['user_email'];
    1533 
    1534         /**
    1535          * Filters a user's email before the user is created or updated.
    1536          *
    1537          * @since 2.0.3
    1538          *
    1539          * @param string $raw_user_email The user's email.
    1540          */
    1541         $user_email = apply_filters( 'pre_user_email', $raw_user_email );
    1542 
    15431547        /*
    15441548         * If there is no update, just check for `email_exists`. If there is an update,
    15451549         * check if current email and new email are the same, or not, and check `email_exists`