Make WordPress Core

Changeset 14226


Ignore:
Timestamp:
04/24/2010 06:39:22 PM (14 years ago)
Author:
wpmuguru
Message:

fix site administrator add user to site logic, see #12488

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-includes/ms-functions.php

    r14222 r14226  
    253253    $user = new WP_User($user_id);
    254254
    255     if ( empty($user) )
     255    if ( empty($user) || !$user->ID )
    256256        return new WP_Error('user_does_not_exist', __('That user does not exist.'));
    257257
     
    13181318
    13191319    $details = get_option( 'new_user_' . $key );
    1320     add_existing_user_to_blog( $details );
    1321     delete_option( 'new_user_' . $key );
    1322     wp_die( sprintf(__('You have been added to this blog. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url() ) );
     1320    if ( !empty( $details ) )
     1321        delete_option( 'new_user_' . $key );
     1322
     1323    if ( empty( $details ) || is_wp_error( add_existing_user_to_blog( $details ) ) )
     1324        wp_die( sprintf(__('An error occurred adding you to this site. Back to the <a href="%s">homepage</a>.'), site_url() ) );
     1325   
     1326    wp_die( sprintf(__('You have been added to this site. Please visit the <a href="%s">homepage</a> or <a href="%s">login</a> using your username and password.'), site_url(), admin_url() ), __('Success') );
    13231327}
    13241328
    13251329function add_existing_user_to_blog( $details = false ) {
    13261330    if ( is_array( $details ) ) {
    1327         add_user_to_blog( '', $details[ 'user_id' ], $details[ 'role' ] );
    1328         do_action( 'added_existing_user', $details[ 'user_id' ] );
    1329     }
     1331        $result = add_user_to_blog( '', $details[ 'user_id' ], $details[ 'role' ] );
     1332        do_action( 'added_existing_user', $details[ 'user_id' ], $result );
     1333    }
     1334    return $result;
    13301335}
    13311336
Note: See TracChangeset for help on using the changeset viewer.