Hey,
So I was messing around and something like the following should work:
add_filter( 'ef_editorial_metadata_user_dropdown_args', 'efx_editorial_metadata_user_dropdown_args' );
function efx_editorial_metadata_user_dropdown_args( $args ) {
if( $args['name'] == '_ef_editorial_meta_user_user-assigned' ) {
global $current_user;
get_currentuserinfo();
if( !in_array( 'contributor', $current_user->wp_capabilities ) )
return $args;
$contributors = get_users( array( 'role' => 'editor' ) );
$contributor_ids = '';
if( empty( $contributors ) )
return $args;
foreach( $contributors as $user ) {
$contributor_ids .= $user->data->ID . ',';
}
$args['include'] = $contributor_ids;
}
return $args;
}
I’ll walk through it real quick.
Here we’re registering the filter for all editorial metadata that is the type user.
add_filter( 'ef_editorial_metadata_user_dropdown_args', 'efx_editorial_metadata_user_dropdown_args' );
The next part is the only part you will probably have to modify before placing in functions.php:
if( $args['name'] == '_ef_editorial_meta_user_user-assigned' )
In this snippet we’re checking which editorial metadata it is (in the event we have multiple editorial metadata’s that are of the type “user”). I gave my editorial metadata the slug user-assigned. If you gave your editorial metadata the slug users-are-cool, then yours would probably look like:
if( $args['name'] == '_ef_editorial_meta_user_users-are-cool' )
.
Here we’re checking if the user is a contributor:
if( !in_array( 'contributor', $current_user->wp_capabilities ) )
return $args;
*This doesn’t check capabilities, it checks the user role. This shouldn’t cause any bugs, but keep an eyeball on it.
Lastly, we’re getting all the users that are editors, and we’re going to have our dropdown just show those:
foreach( $contributors as $user ) {
$contributor_ids .= $user->data->ID . ',';
}
$args['include'] = $contributor_ids;
Hopefully this works! Definitely reply back here if you need any help!