Make WordPress Core

Changeset 58999


Ignore:
Timestamp:
09/09/2024 10:15:24 AM (5 weeks ago)
Author:
SergeyBiryukov
Message:

Users: Remove obsolete conditional in wp-admin/user-new.php.

Since $username is set to $user_details->user_login, it will never be null in this specific line.

Follow-up to mu:641, mu:1529, [12722], [16294].

Props akshat2802, mukesh27, aristath, SergeyBiryukov.
Fixes #62012.

File:
1 edited

Legend:

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

    r57274 r58999  
    3535    $user_details = null;
    3636    $user_email   = wp_unslash( $_REQUEST['email'] );
     37
    3738    if ( str_contains( $user_email, '@' ) ) {
    3839        $user_details = get_user_by( 'email', $user_email );
     
    6465    $username       = $user_details->user_login;
    6566    $user_id        = $user_details->ID;
    66     if ( null != $username && array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
     67
     68    if ( array_key_exists( $blog_id, get_blogs_of_user( $user_id ) ) ) {
    6769        $redirect = add_query_arg( array( 'update' => 'addexisting' ), 'user-new.php' );
    6870    } else {
     
    179181        }
    180182    }
     183
    181184    wp_redirect( $redirect );
    182185    die();
     
    203206                $redirect = add_query_arg( 'update', 'add', 'user-new.php' );
    204207            }
     208
    205209            wp_redirect( $redirect );
    206210            die();
     
    210214        $new_user_email = wp_unslash( $_REQUEST['email'] );
    211215        $user_details   = wpmu_validate_user_signup( $_REQUEST['user_login'], $new_user_email );
     216
    212217        if ( is_wp_error( $user_details['errors'] ) && $user_details['errors']->has_errors() ) {
    213218            $add_user_errors = $user_details['errors'];
     
    215220            /** This filter is documented in wp-includes/user.php */
    216221            $new_user_login = apply_filters( 'pre_user_login', sanitize_user( wp_unslash( $_REQUEST['user_login'] ), true ) );
     222
    217223            if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
    218224                add_filter( 'wpmu_signup_user_notification', '__return_false' );  // Disable confirmation email.
    219225                add_filter( 'wpmu_welcome_user_notification', '__return_false' ); // Disable welcome email.
    220226            }
     227
    221228            wpmu_signup_user(
    222229                $new_user_login,
     
    227234                )
    228235            );
     236
    229237            if ( isset( $_POST['noconfirmation'] ) && current_user_can( 'manage_network_users' ) ) {
    230238                $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 ) );
     
    246254                $redirect = add_query_arg( array( 'update' => 'newuserconfirmation' ), 'user-new.php' );
    247255            }
     256
    248257            wp_redirect( $redirect );
    249258            die();
Note: See TracChangeset for help on using the changeset viewer.