Hi
I want to be able to set a custom role as the author on my CPTs so they can then edit them in the front end.
I follow the advice here: https://toolset.com/forums/topic/cant-add-new-user-with-new-custom-role-as-author/
But this then only shows this custom role as possible authors when I want to be able to set admins, editors still as well. Any ideas?
Thanks
Raja Mohammed
Supporter
Languages:
English (English )
Timezone:
Asia/Kolkata (GMT+05:30)
Hello there
In the code mentioned in the referred ticket, You can specify multiple roles as an array of roles by replacing $query_args['role'] with $query_args['role__in']
$query_args['role__in'] = array( 'contributor', 'administrator' );
the final code would be like
function wpdocs_add_members_to_dropdown( $query_args, $r ) {
// Add multiple roles
$query_args['role__in'] = array('member','editor','administrator');
// 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 );
Reference : https://developer.wordpress.org/reference/hooks/wp_dropdown_users_args/#comment-4087
I hope that helps.
Regards
Raja
I did actually try this but I added a space between the arrays! I was guessing I don't know much about PHP.
Thanks for your help. I should have double checked my work on Google.