Don't use hard-coded indexes when dealing with an array of roles. props elyobo. fixes #19222.
git-svn-id: https://develop.svn.wordpress.org/trunk@21866 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
9447d32ef4
commit
fee76161e3
@ -1022,13 +1022,15 @@ function wp_ajax_add_user( $action ) {
|
||||
|
||||
$wp_list_table = _get_list_table('WP_Users_List_Table');
|
||||
|
||||
$role = current( $user_object->roles );
|
||||
|
||||
$x = new WP_Ajax_Response( array(
|
||||
'what' => 'user',
|
||||
'id' => $user_id,
|
||||
'data' => $wp_list_table->single_row( $user_object, '', $user_object->roles[0] ),
|
||||
'data' => $wp_list_table->single_row( $user_object, '', $role ),
|
||||
'supplemental' => array(
|
||||
'show-link' => sprintf(__( 'User <a href="#%s">%s</a> added' ), "user-$user_id", $user_object->user_login),
|
||||
'role' => $user_object->roles[0]
|
||||
'role' => $role,
|
||||
)
|
||||
) );
|
||||
$x->send();
|
||||
|
@ -786,7 +786,7 @@ class WP_User {
|
||||
foreach ( (array) $this->roles as $oldrole )
|
||||
unset( $this->caps[$oldrole] );
|
||||
|
||||
if ( 1 == count( $this->roles ) && $role == $this->roles[0] )
|
||||
if ( 1 == count( $this->roles ) && $role == current( $this->roles ) )
|
||||
return;
|
||||
|
||||
if ( !empty( $role ) ) {
|
||||
|
Loading…
Reference in New Issue
Block a user