[wp-trac] [WordPress Trac] #60592: Redefining roles

WordPress Trac noreply at wordpress.org
Wed Feb 21 16:53:51 UTC 2024


#60592: Redefining roles
--------------------------+-----------------------------
 Reporter:  n1ck500       |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  Plugins       |    Version:
 Severity:  critical      |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 My plugin code:

 array_shift( wp_get_current_user()->roles );

 Replaces all roles

 print_r( wp_get_current_user() );

 Result:
 ...
 [roles] => Array
         (
         )
 ...

 This affects other plugins that use this function call. Another example:

 wp_get_current_user()->roles = [ 1, 2 ];

 Function result:
 ...
 [roles] => Array
         (
             [0] => 1
             [1] => 2
         )
 ...

 Should it be like this?

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/60592>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list