Make WordPress Core


Ignore:
Timestamp:
04/01/2015 06:22:16 PM (9 years ago)
Author:
wonderboymusic
Message:

When updating the email address for an existing user, make sure the email address is not already in use.

Adds unit tests.

Props rittesh.patel, DrewAPicture.
Fixes #30647.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/user.php

    r31883 r31963  
    18951895    $user_email = apply_filters( 'pre_user_email', $raw_user_email );
    18961896
    1897     if ( ! $update && ! defined( 'WP_IMPORTING' ) && email_exists( $user_email ) ) {
     1897    /*
     1898     * If there is no update, just check for `email_exists`. If there is an update,
     1899     * check if current email and new email are the same, or not, and check `email_exists`
     1900     * accordingly.
     1901     */
     1902    if ( ( ! $update || ( ! empty( $old_user_data ) && $user_email !== $old_user_data->user_email ) )
     1903        && ! defined( 'WP_IMPORTING' )
     1904        && email_exists( $user_email )
     1905    ) {
    18981906        return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) );
    18991907    }
Note: See TracChangeset for help on using the changeset viewer.