[wp-trac] [WordPress Trac] #61100: 'Change role' field on wp-admin/network/site-users.php?id=xxx contains a bug

WordPress Trac noreply at wordpress.org
Wed May 29 10:50:05 UTC 2024


#61100: 'Change role' field on wp-admin/network/site-users.php?id=xxx contains a
bug
--------------------------------------+------------------------
 Reporter:  ignatiusjeroe             |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  6.6
Component:  Networks and Sites        |     Version:
 Severity:  normal                    |  Resolution:
 Keywords:  good-first-bug has-patch  |     Focuses:  multisite
--------------------------------------+------------------------

Comment (by techpartho):

 Here is my suggestion, To fix this, we should modify the case 'promote'
 section in wp-admin/network/site-users.php to handle the 'none' role
 similarly to how it's dealt with in wp-admin/users.php.

 Here are the steps to fix this issue:

 1. Add a mock none-role to $editable_roles:


 {{{
 $editable_roles['none'] = array(
     'name' => __( '— No role for this site —' ),
 );

 }}}

 2. Update the if-statement to handle the 'none' role properly:


 {{{
 if ( ! $role || empty( $editable_roles[ $role ] ) ) {
     wp_die( __( 'Sorry, you are not allowed to give users that role.' ),
 403 );
 }

 if ( 'none' === $role ) {
     $role = '';
 }

 }}}

 The error will be resolved by implementing these changes, and selecting
 "-No role for this site-" will work correctly without triggering an error.
 This solution aligns the behavior of wp-admin/network/site-users.php with
 wp-admin/users.php.

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/61100#comment:3>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list