WordPress.org

Make WordPress Core

Opened 7 years ago

Closed 6 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 7 years ago.
Adds an 'id' parameter to wp_dropdown_users()
12132_categories.patch (1.8 KB) - added by johnbillion 7 years ago.
Adds an 'id' parameter to wp_dropdown_categories()

Download all attachments as: .zip

Change History (8)

#1 @johnbillion
7 years ago

  • Version set to 2.9.1

#2 @scribu
7 years ago

  • Milestone changed from Unassigned to 3.0

@johnbillion
7 years ago

Adds an 'id' parameter to wp_dropdown_users()

#3 @johnbillion
7 years ago

  • Keywords has-patch added

El patcho.

@johnbillion
7 years ago

Adds an 'id' parameter to wp_dropdown_categories()

#4 @johnbillion
7 years ago

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

#5 @nacin
6 years ago

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

#6 @nacin
6 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.