Edit Flow

Limit custom statuses based on user role

In v0.7.2, we added the ability for users without the ‘publish_posts’ capability to use any of your custom statuses — not just “Draft” and “Pending Review.” If you’d like to enforce a more structured workflow, it’s now an easy thing to restrict access to specific post statuses based on user role, capabilities or user group relationship. If a user doesn’t have access to a given status, they’ll still be able to edit the post when it’s saved with that status.

If you haven’t already, please read the introduction to extending Edit Flow. Once you’ve done so, you can modify the example below to your needs. This particular example limits the post statuses available to a user with the “Contributor” role.

[sourcecode language=”php”]
* Limit custom statuses based on user role
* In this example, we limit the statuses available to the
* ‘contributor’ user role
* @see http://editflow.org/extend/limit-custom-statuses-based-on-user-role/
* @param array $custom_statuses The existing custom status objects
* @return array $custom_statuses Our possibly modified set of custom statuses
function efx_limit_custom_statuses_by_role( $custom_statuses ) {

$current_user = wp_get_current_user();
switch( $current_user->roles[0] ) {
// Only allow a contributor to access specific statuses from the dropdown
case ‘contributor’:
$permitted_statuses = array(
// Remove the custom status if it’s not whitelisted
foreach( $custom_statuses as $key => $custom_status ) {
if ( !in_array( $custom_status->slug, $permitted_statuses ) )
unset( $custom_statuses[$key] );
return $custom_statuses;
add_filter( ‘ef_custom_status_list’, ‘efx_limit_custom_statuses_by_role’ );

Exit mobile version