Make WordPress Core


Ignore:
Timestamp:
08/06/2026 03:38:58 PM (3 months ago)
Author:
johnbillion
Message:

Users: Ensure a proper email address is used before sending email confirmations.

Props xknown, westonruter, jeremyfelt, peterwilsoncc, paulkevan, lucasbustamante, jorbin, desrosj.

File:
1 edited

Legend:

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

    r62688 r63065  
    4545        }
    4646
     47        $errors = new WP_Error();
     48
    4749        $pass1 = '';
    4850        $pass2 = '';
    … …  
    7981
    8082        if ( isset( $_POST['email'] ) ) {
    81                 $user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
     83                $maybe_email = wp_unslash( $_POST['email'] );
     84                if ( is_string( $maybe_email ) && is_email( $maybe_email ) ) {
     85                        $user->user_email = $maybe_email;
     86                } else {
     87                        $errors->add( 'invalid_email', __( '<strong>Error:</strong> The email address is not correct.' ), array( 'form-field' => 'email' ) );
     88                }
    8289        }
    8390        if ( isset( $_POST['url'] ) ) {
    … …  
    146153                $user->use_ssl = 1;
    147154        }
    148 
    149         $errors = new WP_Error();
    150155
    151156        /* checking that username has been typed */
Note: See TracChangeset for help on using the changeset viewer.