Prevent authors to directly publish posts – WordPress

If you're running a blog or a magazine & want your authors not to directly publish posts on your blog or magazine, simply put the following code in your functions.php & your problem is solved.

If you’re running a blog or a magazine & want your authors not to directly publish posts on your blog or magazine, simply put the following code in your functions.php & your problem is solved.

function remove_author_publish_posts(){

    // $wp_roles is an instance of WP_Roles.
    global $wp_roles;
    $wp_roles->remove_cap( 'author', 'publish_posts' );
}

add_action( 'init', 'remove_author_publish_posts' );

What this piece of code does?

It removes the capability from author to publish posts directly & change the value of the publish button to “Submit for review” for the administrator.

Try it yourself & let us know if you get stuck at any point.

Comments