Make WordPress Core

Opened 6 years ago

Closed 6 years ago

Last modified 6 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's profile 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
6 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
6 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.