email_exists example


    $user_email = apply_filters( 'pre_user_email', $raw_user_email );

    /* * If there is no update, just check for `email_exists`. If there is an update, * check if current email and new email are the same, and check `email_exists` * accordingly. */
    if ( ( ! $update || ( ! empty( $old_user_data ) && 0 !== strcasecmp( $user_email$old_user_data->user_email ) ) )
        && ! defined( 'WP_IMPORTING' )
        && email_exists( $user_email )
    ) {
        return new WP_Error( 'existing_user_email', __( 'Sorry, that email address is already used!' ) );
    }

    $raw_user_url = empty( $userdata['user_url'] ) ? '' : $userdata['user_url'];

    /** * Filters a user's URL before the user is created or updated. * * @since 2.0.3 * * @param string $raw_user_url The user's URL. */


    if ( is_subdomain_install() ) {
        $newdomain = $domain . '.' . preg_replace( '|^www\.|', '', get_network()->domain );
        $path      = get_network()->path;
    } else {
        $newdomain = get_network()->domain;
        $path      = get_network()->path . $domain . '/';
    }

    $password = 'N/A';
    $user_id  = email_exists( $email );
    if ( ! $user_id ) { // Create a new user with a random password.         /** * Fires immediately before a new user is created via the network site-new.php page. * * @since 4.5.0 * * @param string $email Email of the non-existent user. */
        do_action( 'pre_network_site_new_created_user', $email );

        $user_id = username_exists( $domain );
        

    public function update_item( $request ) {
        $user = $this->get_user( $request['id'] );
        if ( is_wp_error( $user ) ) {
            return $user;
        }

        $id = $user->ID;

        $owner_id = false;
        if ( is_string( $request['email'] ) ) {
            $owner_id = email_exists( $request['email'] );
        }

        if ( $owner_id && $owner_id !== $id ) {
            return new WP_Error(
                'rest_user_invalid_email',
                __( 'Invalid email address.' ),
                array( 'status' => 400 )
            );
        }

        if ( ! empty( $request['username'] ) && $request['username'] !== $user->user_login ) {
            
if ( in_array( strtolower( $user->user_login )array_map( 'strtolower', $illegal_logins ), true ) ) {
        $errors->add( 'invalid_username', __( '<strong>Error:</strong> Sorry, that username is not allowed.' ) );
    }

    // Checking email address.     if ( empty( $user->user_email ) ) {
        $errors->add( 'empty_email', __( '<strong>Error:</strong> Please enter an email address.' ), array( 'form-field' => 'email' ) );
    } elseif ( ! is_email( $user->user_email ) ) {
        $errors->add( 'invalid_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email' ) );
    } else {
        $owner_id = email_exists( $user->user_email );
        if ( $owner_id && ( ! $update || ( $owner_id !== $user->ID ) ) ) {
            $errors->add( 'email_exists', __( '<strong>Error:</strong> This email is already registered. Please choose another one.' ), array( 'form-field' => 'email' ) );
        }
    }

    /** * Fires before user profile update errors are returned. * * @since 2.8.0 * * @param WP_Error $errors WP_Error object (passed by reference). * @param bool $update Whether this is a user update. * @param stdClass $user User object (passed by reference). */
if ( ! in_array( $emaildomain$limited_email_domains, true ) ) {
            $errors->add( 'user_email', __( 'Sorry, that email address is not allowed!' ) );
        }
    }

    // Check if the username has been used already.     if ( username_exists( $user_name ) ) {
        $errors->add( 'user_name', __( 'Sorry, that username already exists!' ) );
    }

    // Check if the email address has been used already.     if ( email_exists( $user_email ) ) {
        $errors->add(
            'user_email',
            sprintf(
                /* translators: %s: Link to the login page. */
                __( '<strong>Error:</strong> This email address is already registered. <a href="%s">Log in</a> with this address or choose another one.' ),
                wp_login_url()
            )
        );
    }

    // Has someone already signed up for this username?
Home | Imprint | This part of the site doesn't use cookies.