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:
Andrew Nacin 2012-09-16 16:24:33 +00:00
parent 9447d32ef4
commit fee76161e3
2 changed files with 5 additions and 3 deletions

View File

@ -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();

View File

@ -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 ) ) {