Allow apostrophes in email addresses when adding users via the Dashboard.
Email addresses entered in a number of interfaces were not being stripslashed properly, with the result that the emails were not being recognized as valid. Fixes #18039. git-svn-id: https://develop.svn.wordpress.org/trunk@29966 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
348c8958da
commit
5bc62ad1e4
@ -63,7 +63,7 @@ function edit_user( $user_id = 0 ) {
|
||||
}
|
||||
|
||||
if ( isset( $_POST['email'] ))
|
||||
$user->user_email = sanitize_text_field( $_POST['email'] );
|
||||
$user->user_email = sanitize_text_field( wp_unslash( $_POST['email'] ) );
|
||||
if ( isset( $_POST['url'] ) ) {
|
||||
if ( empty ( $_POST['url'] ) || $_POST['url'] == 'http://' ) {
|
||||
$user->user_url = '';
|
||||
|
@ -38,14 +38,14 @@ if ( isset($_REQUEST['action']) && 'add-user' == $_REQUEST['action'] ) {
|
||||
if ( ! is_array( $_POST['user'] ) )
|
||||
wp_die( __( 'Cannot create an empty user.' ) );
|
||||
|
||||
$user = $_POST['user'];
|
||||
$user = wp_unslash( $_POST['user'] );
|
||||
|
||||
$user_details = wpmu_validate_user_signup( $user['username'], $user['email'] );
|
||||
if ( is_wp_error( $user_details[ 'errors' ] ) && ! empty( $user_details[ 'errors' ]->errors ) ) {
|
||||
$add_user_errors = $user_details[ 'errors' ];
|
||||
} else {
|
||||
$password = wp_generate_password( 12, false);
|
||||
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, esc_html( $user['email'] ) );
|
||||
$user_id = wpmu_create_user( esc_html( strtolower( $user['username'] ) ), $password, sanitize_email( $user['email'] ) );
|
||||
|
||||
if ( ! $user_id ) {
|
||||
$add_user_errors = new WP_Error( 'add_user_fail', __( 'Cannot add user.' ) );
|
||||
|
@ -41,11 +41,12 @@ if ( isset($_REQUEST['action']) && 'adduser' == $_REQUEST['action'] ) {
|
||||
check_admin_referer( 'add-user', '_wpnonce_add-user' );
|
||||
|
||||
$user_details = null;
|
||||
if ( false !== strpos($_REQUEST[ 'email' ], '@') ) {
|
||||
$user_details = get_user_by('email', $_REQUEST[ 'email' ]);
|
||||
$user_email = wp_unslash( $_REQUEST['email'] );
|
||||
if ( false !== strpos( $user_email, '@' ) ) {
|
||||
$user_details = get_user_by( 'email', $user_email );
|
||||
} else {
|
||||
if ( is_super_admin() ) {
|
||||
$user_details = get_user_by('login', $_REQUEST[ 'email' ]);
|
||||
$user_details = get_user_by( 'login', $user_email );
|
||||
} else {
|
||||
wp_redirect( add_query_arg( array('update' => 'enter_email'), 'user-new.php' ) );
|
||||
die();
|
||||
@ -112,7 +113,8 @@ Please click the following link to confirm the invite:
|
||||
}
|
||||
} else {
|
||||
// Adding a new user to this site
|
||||
$user_details = wpmu_validate_user_signup( $_REQUEST[ 'user_login' ], $_REQUEST[ 'email' ] );
|
||||
$new_user_email = wp_unslash( $_REQUEST['email'] );
|
||||
$user_details = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
|
||||
if ( is_wp_error( $user_details[ 'errors' ] ) && !empty( $user_details[ 'errors' ]->errors ) ) {
|
||||
$add_user_errors = $user_details[ 'errors' ];
|
||||
} else {
|
||||
@ -128,9 +130,9 @@ Please click the following link to confirm the invite:
|
||||
add_filter( 'wpmu_signup_user_notification', '__return_false' ); // Disable confirmation email
|
||||
add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email
|
||||
}
|
||||
wpmu_signup_user( $new_user_login, $_REQUEST[ 'email' ], array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST[ 'role' ] ) );
|
||||
wpmu_signup_user( $new_user_login, $new_user_email, array( 'add_to_blog' => $wpdb->blogid, 'new_role' => $_REQUEST['role'] ) );
|
||||
if ( isset( $_POST[ 'noconfirmation' ] ) && is_super_admin() ) {
|
||||
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $_REQUEST[ 'email' ] ) );
|
||||
$key = $wpdb->get_var( $wpdb->prepare( "SELECT activation_key FROM {$wpdb->signups} WHERE user_login = %s AND user_email = %s", $new_user_login, $new_user_email ) );
|
||||
wpmu_activate_signup( $key );
|
||||
$redirect = add_query_arg( array('update' => 'addnoconfirmation'), 'user-new.php' );
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user