Prevent authors to directly publish posts – WordPress

September 5, 2017 By - Usama Muneer | 1079

    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.

    blog user
    Usama Muneer

    A web enthusiastic, self-motivated & detail-oriented professional Full-Stack Web Developer from Karachi, Pakistan with experience in developing applications using JavaScript, WordPress & Laravel specifically. Loves to write on different web technologies with an equally useful skill to make some sense out of it.

    Related Posts

    We're not web designers, but rather we comprehend what it takes to make an extraordinary website utilising WordPress. Gratefully, we've been sufficiently fortunate to discover a huge amount of extraordinary web designers who know their stuff

    Once you become the owner of your WordPress’s website, you accept the ownership and try to build it in every way possible. But doing it the wrong way can leave you barehanded in the end. Yes, we are talking about the shortcuts that are mostly illegal and overlooks privacy.

    If you have encountered an error wp.media not defined while uploading images for your WordPress custom posts or taxonomies.

    If you're running a WordPress website or blog, its always a good practice to setup some sort of security for your admin area & restrict access for smart users.