Update wp_dropdown_users( $args = '' ) to support a proper select option value HTML attribute

Context

Maybe because WordPress does not like to consider its users (pun intended) it also neglects its functions that deal with “users”.

So for example the wp_dropdown_users( $args = '' ) function produces a select with all users, but it does not let you change the value of those select options

I am not sure why this feature was omitted, but as said, maybe it has to do with WP and Users not being on a nice path anyway :stuck_out_tongue:

I amended that function in my plugins already quite some time ago as I need a customisable value attribute in the select option.
The change simply adds one new argument:

@type string $value_field User `data` object values to use as selection option **value**. Accepts any User `data` object property. Default to user ID.

BTW, this is already done in core’s wp_dropdown_categories, so there is no reason not to do it in wp_dropdown_users() as well.

Will you be able to help with the implementation?

Already done, just need to PR it.

If you do not want to waste votes also a comment will do for me.

Voted, sounds like a good modification to the function.

Same as the other two petitions of this type, add a new parameter to $args rather than to the function itself, and this can go in as soon as there’s a PR for it :+1:

1 Like

PR

3 Likes

Great job @smileBeda. Since this petition has a pull request now, I’ve updated its status and will set it to close to release votes. Any discussions related to PR should be done on GitHub.

2 Likes

This topic was automatically closed after 5 days. New replies are no longer allowed.