Not Working – Limit Customer Statuses Based on Roles
-
I stalled the following code, however it doesn’t work. Well, perhaps it works too well. After installation all the statuses disappear, therefore the contributor can’t select any status at all. I tried changing the code in several different ways, however each time I put it in the statuses disappear. What could be the problem?
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(
‘in-progress’,
‘pending’,
);
// 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] );
}
break;
}
return $custom_statuses;
}
add_filter( ‘ef_custom_status_list’, ‘efx_limit_custom_statuses_by_role’ );
- The topic ‘Not Working – Limit Customer Statuses Based on Roles’ is closed to new replies.