WordPress.org

Make WordPress Core

Opened 3 years ago

Last modified 20 months ago

#30175 assigned defect (bug)

In multisite, on a site with only subscribers, wp_dropdown_users returns empty string

Reported by: johnjamesjacoby Owned by: jeremyfelt
Milestone: Future Release Priority: normal
Severity: normal Version:
Component: Users Keywords: has-patch
Focuses: multisite Cc:

Description

This becomes a problem when editing posts on sites with no capable users. Technically, an empty string is the expected result, as the site has no users with adequate capabilities to assign as the author of a post. (I'll propose 1 solution in a comment below.)

To duplicate:

  • Setup multisite
  • Create a second site
  • Add a user to it as a Subscriber
  • Remove yourself from that site, if necessary
  • Edit the "Hello World" post
  • Notice the "Author" metabox is empty

Attachments (1)

3175.patch (818 bytes) - added by johnjamesjacoby 3 years ago.

Download all attachments as: .zip

Change History (5)

#1 @johnjamesjacoby
3 years ago

  • Keywords has-patch added; needs-patch removed

The proposed patch is admittedly not super great, but I think it's an acceptable approach.

If no users on the current site are capable of being listed in the dropdown, (I think) we can safely assume any super administrators are. The attached patch:

  • Checks if the call to get_users() returned no results
  • Checks if is_multisite()
  • Checks if the current logged in user is_super_admin (as only super admins should be able to assign other super admins.)
  • Queries for super admins using an approach similar to what's already in: WP_MS_Users_List_Table->prepare_items()

#2 @jeremyfelt
3 years ago

  • Focuses multisite added
  • Milestone changed from Awaiting Review to Future Release

#3 @wonderboymusic
2 years ago

  • Owner set to jeremyfelt
  • Status changed from new to assigned

This ticket was mentioned in Slack in #core-multisite by richardtape. View the logs.


20 months ago

Note: See TracTickets for help on using tickets.