I am using a function to create new user roles and delete some defaults. However, they are not showing up in the post author box! Only the admin shows up because they are selected as an admin. Any user with a custom role does not show up. Any idea why this would be happening?
Here is my function:
// Add New User Roles
function add_new_roles() {
// New Roles To Be Added
$new_roles = array(
array(
'role' => 'senior_pastor',
'display' => 'Senior Pastor'
),
array(
'role' => 'exec_pastor',
'display' => 'Executive Pastor'
),
array(
'role' => 'assoc_pastor',
'display' => 'Associate Pastor'
),
array(
'role' => 'elder',
'display' => 'Elder'
),
array(
'role' => 'ministry_leader',
'display' => 'Ministry Leader'
)
);
foreach($new_roles as $role){
add_role($role['role'], $role['display'], array(
'edit_published_posts' => true,
'upload_files' => true,
'create_product' => true,
'publish_posts' => true,
'delete_published_posts' => true,
'edit_posts' => true,
'delete_posts' => true,
'read' => true
));
}
// Old Roles To Be Removed
$old_roles = array(
'subscriber',
'contributor',
'author'
'editor'
);
foreach($old_roles as $role){
remove_role( $role );
}
}
add_action('after_switch_theme', 'add_new_roles');
Found a workaround below. I guess it has to do with a bug in the WordPress core. This will list ALL users in posts, so be cautious.
credit goes to here
Yes, indeed, it is a bug, as reported in the ticket #16841.
Testing with 3.6-beta3, it’s still there… The workaround is, in scribu’s words:
And… it works as advertised 😉
For reference, these are the places where
wp_dropdown_users
happen in the core: