Advertisement
Aurangajeb

Show all user_role to the change author dropdown option

Oct 2nd, 2021
1,516
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. /** Show all user_role to the change author dropdown option **/
  2. //https://wordpress.org/support/topic/author-dropdown-fails-to-show-users-with-custom-role-that-includes-author-editor/
  3. //https://developer.wordpress.org/reference/hooks/wp_dropdown_users_args/
  4.  
  5. add_action('wp_dropdown_users_args', 'filter_authors');
  6. function filter_authors( $args ) {
  7.     if ( isset( $args['who'])) {
  8.         $args['role__in'] = ['subscriber', 'author', 'editor', 'administrator', 'manager']; //add desires user role
  9.         unset( $args['who']);
  10.     }
  11.     return $args;
  12. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement