[wp-trac] [WordPress Trac] #36961: wp_roles displays incorrect roles in multisite

WordPress Trac noreply at wordpress.org
Thu Sep 22 21:19:11 UTC 2016


#36961: wp_roles displays incorrect roles in multisite
-----------------------------+------------------------------
 Reporter:  ryanduff         |       Owner:
     Type:  defect (bug)     |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Role/Capability  |     Version:  4.2
 Severity:  normal           |  Resolution:
 Keywords:  dev-feedback     |     Focuses:  multisite
-----------------------------+------------------------------

Comment (by flixos90):

 The problem here is that the `WP_Roles` class does not support passing a
 site ID, so it will always retrieve the roles registered on the current
 site. A possible solution for it could be to add a `switch_to_blog()` (and
 `restore_current_blog()`) before the `wp_roles()` call in `WP_User`.

 This switch must only happen if we're on a multisite setup and if the
 `$cap_key` property is different from the one of the current site (and
 then we'd need to extract the site ID out of it, or alternatively find a
 suitable way to directly pass the site ID to the `get_role_caps()`
 method).

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


More information about the wp-trac mailing list