Skip Navigation

[Resolved] Author dropdown and custom roles

This thread is resolved. Here is a description of the problem and solution.

Problem: I would like to add Users in a custom role "Members" to the author select field in the post editor screen.

Solution: Add custom code to your child theme's functions.php file:

function wpdocs_add_members_to_dropdown( $query_args, $r ) {
 
    $query_args['role'] = array('member');
 
    // Unset the 'who' as this defaults to the 'author' role
    unset( $query_args['who'] );
 
    return $query_args;
}
add_filter( 'wp_dropdown_users_args', 'wpdocs_add_members_to_dropdown', 10, 2 );

100% of people find this useful.

This support ticket is created 6 years, 3 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

This topic contains 2 replies, has 2 voices.

Last updated by helenmaryC 6 years, 3 months ago.

Assisted by: Christian Cox.

Author
Posts
#1081510

In WordPress, users with roles of Author, Editor, and Admin appear in the Author dropdown box on posts and custom post types. I would also like for users assigned to my custom role of Member to be shown in the Author dropdown.

I have set the capabilities for Member to include edit_posts, edit_published_posts, publish_posts, and read, mimicking the capabilities of the Author role, but I still can't see Members in the dropdown. Is there another setting I need to make, or is this something that has to be done with code?

Thanks.

#1081528

Hi, you can add some custom code to your child theme's functions.php file to add Members to this dropdown:

function wpdocs_add_members_to_dropdown( $query_args, $r ) {

    $query_args['role'] = array('member');

    // Unset the 'who' as this defaults to the 'author' role
    unset( $query_args['who'] );

    return $query_args;
}
add_filter( 'wp_dropdown_users_args', 'wpdocs_add_members_to_dropdown', 10, 2 );
#1081714

Worked like a charm! Thanks for your help.