Actually, I think I figured it out. I added:
function disable_authors_publish_cap() {
// Get author role object
$author = get_role( 'editor' );
// Remove the post publishing capability
$author->remove_cap( 'publish_posts' );
}
add_action( 'init', 'disable_authors_publish_cap' );
to my functions.php after the EXTEND functions for Edit flow. It now looks like this:
/**
* Hide the "Publish" button until a post is ready to be published
*/
function efx_hide_publish_button_until() {
if ( ! function_exists( 'EditFlow' ) )
return;
if ( ! EditFlow()->custom_status->is_whitelisted_page() )
return;
// Show the publish button if the post has one of these statuses
$show_publish_button_for_status = array(
'ready-for-publish',
// The statuses below are WordPress' public statuses
'future',
'publish',
'schedule',
'private',
);
if ( ! in_array( get_post_status(), $show_publish_button_for_status ) ) {
?>
<style>
#publishing-action { display: none; }
</style>
<?php
}
}
add_action( 'admin_head', 'efx_hide_publish_button_until' );
/**
* 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 'author':
$permitted_statuses = array(
'pending',
'pitch',
'draft',
'in-progress',
);
// 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' );
/**
* Remove Publish Capabilities for Editors
*/
function disable_authors_publish_cap() {
// Get author role object
$author = get_role( 'editor' );
// Remove the post publishing capability
$author->remove_cap( 'publish_posts' );
}
add_action( 'init', 'disable_authors_publish_cap' );
However, is this the best way to accomplish what I am after or is there a better way?
Looks good to me. Have you tried it out?
*Note: I think when you remove the publish_posts
capability the publish button won’t show. So you may not need all that extra code.