[wp-trac] [WordPress Trac] #53231: wp_get_current_user() doesn't return roles and capabilities on a multisite

WordPress Trac noreply at wordpress.org
Wed May 19 10:23:00 UTC 2021


#53231: wp_get_current_user() doesn't return roles and capabilities on a multisite
--------------------------+-----------------------------
 Reporter:  moon0326      |      Owner:  (none)
     Type:  defect (bug)  |     Status:  new
 Priority:  normal        |  Milestone:  Awaiting Review
Component:  General       |    Version:
 Severity:  normal        |   Keywords:
  Focuses:                |
--------------------------+-----------------------------
 wp_get_current_user() doesn't return roles and capabilities on a multisite
 even when you're logged in as a super admin. This is causing
 https://github.com/woocommerce/woocommerce-admin/issues/7004

 How to test:

 1. Create a new multisite
 2. Make sure to turn on

 define( 'WP_DEBUG', true
 define( 'WP_DEBUG_LOG', true )

 3. Add a new site. Use a different email address than the admin email.
 4. Use this plugin (copy from this
 https://gist.github.com/moon0326/34551bd7cedbd633e7d510ba9fca35d9) to
 print return value of wp_get_current_user().
 5. Open terminal and cd to :your-wordpress-dir/wp-content/ and start
 tailing debug.log
 6. Visit the new site. Notice that the WP_User object has no roles.
 7. Go back to the original site. Notice that the WP_User object has roles
 now.

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


More information about the wp-trac mailing list