[wp-trac] [WordPress Trac] #46451: wp_dropdown_users() does not pass all applicable arguments on to get_users()
WordPress Trac
noreply at wordpress.org
Fri Mar 8 23:45:16 UTC 2019
#46451: wp_dropdown_users() does not pass all applicable arguments on to
get_users()
--------------------------+------------------------------
Reporter: pbiron | Owner: (none)
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Users | Version:
Severity: normal | Resolution:
Keywords: | Focuses:
--------------------------+------------------------------
Comment (by pbiron):
Replying to [comment:1 pbiron]:
> There are a couple of ways this could be achieved, I list a few
below...and I'm sure there are others as well.
maybe the cleanest way would be to modify `wp_array_slice_assoc()` to
accept an `$invert` param (which would be useful in and of itself):
{{{#!php
<?php
function wp_array_slice_assoc( $array, $keys, $invert = false ) {
$slice = array();
if ( ! $invert ) {
foreach ( $keys as $key ) {
if ( isset( $array[ $key ] ) ) {
$slice[ $key ] = $array[ $key ];
}
}
}
else {
foreach ( array_keys( $array ) as $key ) {
if ( ! in_array( $key, $keys ) ) {
$slice[ $key ] = $array[ $key ];
}
}
}
return $slice;
}
}}}
and then just use:
{{{#!php
<?php
$blacklist = array(
'show_option_all',
'show_option_none',
'hide_if_only_one_author',
'multi',
'show',
'echo',
'selected',
'name',
'class',
'id',
'include_selected',
'option_none_value',
);
$query_args = wp_array_slice_assoc( $r, $blacklist, true );
...
$users = get_users( $query_args );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/46451#comment:2>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list