WordPress.org

Make WordPress Core

Opened 4 years ago

Closed 4 years ago

#12132 closed enhancement (fixed)

wp_dropdown_users() needs an 'id' parameter to allow it to work with the widgets API

Reported by: johnbillion Owned by: nacin
Milestone: 3.0 Priority: normal
Severity: minor Version: 2.9.1
Component: Users Keywords: wp_dropdown_users widgets has-patch
Focuses: Cc:

Description

It's not possible to use wp_dropdown_users() to display a dropdown of users on a widget administration screen (ie. in the form() function of the widget). The reason is that you cannot explicitly pass an 'id' parameter to the dropdown, which is a requirement of the AJAX functionality of the widget admin screen.

The problem is that wp_dropdown_users() uses the value of the 'name' parameter to populate both the name and the id of the dropdown. The AJAX functionality of the widget admin screen requires that the ID and name use explicit values from get_field_id() and get_field_name() respectively.

Patch coming up when I get a chance. There may also be other API functions that have the same problem.

Attachments (2)

12132.patch (1.2 KB) - added by johnbillion 4 years ago.
Adds an 'id' parameter to wp_dropdown_users()
12132_categories.patch (1.8 KB) - added by johnbillion 4 years ago.
Adds an 'id' parameter to wp_dropdown_categories()

Download all attachments as: .zip

Change History (8)

comment:1 johnbillion4 years ago

  • Version set to 2.9.1

comment:2 scribu4 years ago

  • Milestone changed from Unassigned to 3.0

johnbillion4 years ago

Adds an 'id' parameter to wp_dropdown_users()

comment:3 johnbillion4 years ago

  • Keywords has-patch added

El patcho.

johnbillion4 years ago

Adds an 'id' parameter to wp_dropdown_categories()

comment:4 johnbillion4 years ago

Additional patch whichs adds an ID parameter to wp_dropdown_categories() too.

comment:5 nacin4 years ago

  • Owner set to nacin
  • Status changed from new to accepted

comment:6 nacin4 years ago

  • Resolution set to fixed
  • Status changed from accepted to closed

(In [13553]) Add id argument to wp_dropdown_users() and wp_dropdown_categories(). props johnbillion. Ensure we're escaping name and id in wp_dropdown_users(). fixes #12132

Note: See TracTickets for help on using tickets.