The 'quick_edit_dropdown_authors_args'
WordPress PHP filter allows you to modify the arguments used for generating the Quick Edit authors drop-down list.
Usage
To use this filter, you can create a custom function and hook it to the filter. Here’s a code example:
function modify_quick_edit_dropdown_authors_args( $users_opt, $bulk ) { // Your custom code return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'modify_quick_edit_dropdown_authors_args', 10, 2 );
Parameters
- $users_opt (array): An array of arguments passed to
wp_dropdown_users()
. - $bulk (bool): A flag to denote if it’s a bulk action.
Examples
Exclude subscribers from the authors dropdown
function exclude_subscribers_from_dropdown( $users_opt, $bulk ) { $users_opt['role__not_in'] = array( 'subscriber' ); return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'exclude_subscribers_from_dropdown', 10, 2 );
This code removes subscribers from the Quick Edit authors dropdown by excluding the ‘subscriber’ role.
Include only specific users in the dropdown
function include_specific_users( $users_opt, $bulk ) { $users_opt['include'] = array( 1, 2, 3 ); return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'include_specific_users', 10, 2 );
This code limits the dropdown to show only users with the IDs 1, 2, and 3.
Exclude specific users from the dropdown
function exclude_specific_users( $users_opt, $bulk ) { $users_opt['exclude'] = array( 4, 5, 6 ); return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'exclude_specific_users', 10, 2 );
This code excludes users with the IDs 4, 5, and 6 from the Quick Edit authors dropdown.
Sort the dropdown by user’s display name
function sort_authors_by_display_name( $users_opt, $bulk ) { $users_opt['orderby'] = 'display_name'; $users_opt['order'] = 'ASC'; return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'sort_authors_by_display_name', 10, 2 );
This code sorts the Quick Edit authors dropdown by the users’ display names in ascending order.
Limit the dropdown to authors with published posts
function limit_authors_with_published_posts( $users_opt, $bulk ) { $users_opt['has_published_posts'] = true; return $users_opt; } add_filter( 'quick_edit_dropdown_authors_args', 'limit_authors_with_published_posts', 10, 2 );
This code limits the Quick Edit authors dropdown to only include authors with published posts in any public post type.