WordPress.org

Make WordPress Core

Changeset 23974


Ignore:
Timestamp:
04/12/2013 01:35:45 PM (5 years ago)
Author:
ryan
Message:

Use API instead of bare SQL queries in site-users.php.

see #21767

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/wp-admin/network/site-users.php

    r21903 r23974  
    8686                $update = 'adduser';
    8787                $newuser = $_POST['newuser'];
    88                 $userid = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . $wpdb->users . " WHERE user_login = %s", $newuser ) );
    89                 if ( $userid ) {
    90                     $blog_prefix = $wpdb->get_blog_prefix( $id );
    91                     $user = $wpdb->get_var( "SELECT user_id FROM " . $wpdb->usermeta . " WHERE user_id='$userid' AND meta_key='{$blog_prefix}capabilities'" );
    92                     if ( $user == false )
    93                         add_user_to_blog( $id, $userid, $_POST['new_role'] );
     88                $user = get_user_by( 'login', $newuser );
     89                if ( $user->exists() ) {
     90                    if ( ! is_user_member_of_blog( $user->ID, $id ) )
     91                        add_user_to_blog( $id, $user->ID, $_POST['new_role'] );
    9492                    else
    9593                        $update = 'err_add_member';
Note: See TracChangeset for help on using the changeset viewer.