WordPress.org

Make WordPress Core

Ticket #22361: 22361.patch

File 22361.patch, 1.4 KB (added by johnjamesjacoby, 6 years ago)
  • wp-admin/includes/class-wp-users-list-table.php

     
    257257                } else {
    258258                        $edit = '<strong>' . $user_object->user_login . '</strong>';
    259259                }
    260                 $role_name = isset( $wp_roles->role_names[$role] ) ? translate_user_role( $wp_roles->role_names[$role] ) : __( 'None' );
     260
     261                // Compare user role against currently editable roles
     262                if ( in_array( $role, array_keys( get_editable_roles() ) ) ) {
     263                        $role_name = translate_user_role( $wp_roles->role_names[$role] );
     264                } else {
     265                        $role_name = __( 'None' );
     266                }
     267
    261268                $avatar = get_avatar( $user_object->ID, 32 );
    262269
    263270                $r = "<tr id='user-$user_object->ID'$style>";
  • wp-admin/user-edit.php

     
    249249<tr><th><label for="role"><?php _e('Role') ?></label></th>
    250250<td><select name="role" id="role">
    251251<?php
    252 // Get the highest/primary role for this user
     252// Compare user role against currently editable roles
    253253// TODO: create a function that does this: wp_get_user_role()
    254 $user_roles = $profileuser->roles;
    255 $user_role = array_shift($user_roles);
     254$user_roles = array_intersect( array_values( $profileuser->roles ), array_keys( get_editable_roles() ) );
     255$user_role  = array_shift( $user_roles );
    256256
    257257// print the full list of roles with the primary one selected.
    258258wp_dropdown_roles($user_role);