WordPress.org

Make WordPress Core

Opened 2 years ago

Closed 2 years ago

Last modified 2 years ago

#43577 closed defect (bug) (worksforme)

On multisite, fetch the current user via wp_get_current_user() returns empty roles array

Reported by: bretweinraub Owned by:
Milestone: Priority: normal
Severity: normal Version:
Component: Users Keywords:
Focuses: multisite Cc:

Description

$user = wp_get_current_user();

var_dump($user->{'roles'});

... prints

{}

Works fine in the root site, but in the subsite, roles is blank.

In the site console, all the role functionality works fine. All plugins are disabled, and I've confirmed that the roles array is blank in a simple page template.

Change History (2)

#1 @bretweinraub99
2 years ago

  • Resolution set to worksforme
  • Status changed from new to closed

I've resolved the issue.

The user in question was a network "Super Admin". Thus, they had all site privileges, without actually having a site role as defined in the WP_User object returned from wp_get_current_user();

#2 @ocean90
2 years ago

  • Component changed from General to Users
  • Focuses multisite added
  • Milestone Awaiting Review deleted
  • Version 4.9.4 deleted
Note: See TracTickets for help on using tickets.