Im currently using User Role editor to modify permission for the user role. I'd like to be able to restrict the role from publishing a post. They can save the draft but they should not be able to publish. Is there a better way to do it?

  • Not sure why you ask this, maybe I am wrong but that's just an option in User Role Editor. Select the role and add it to the role or just leave it inactive imho.
    – Charles
    Feb 21, 2020 at 19:33

2 Answers 2


Give the user the edit_posts capability but not the publish_posts capability.


Use wp_insert_post_data filter. Then check the user role. If user have specific role set-up post status. ( I don't test below script)

add_filter( 'wp_insert_post_data', 'filter_handler', '99');

function filter_handler( $data ) {
    $user = wp_get_current_user();
    $userRole = $user->roles ? $user->roles[0] : false;

    if ( $userRole === 'author') {
        $data['post_status'] = 'pending';

    return $data;
  • where should I place this code? and what is 99? Feb 21, 2020 at 20:03
  • 1
    functions.php, 99 it's a priority Used to specify the order in which the functions associated with a particular action are executed. more about add_filter and priority: developer.wordpress.org/reference/functions/add_filter/… Feb 21, 2020 at 20:12
  • it doesnt work unfortunately. The user can still publish the post. Feb 21, 2020 at 20:23
  • Okay, I did a mistake. Script was updated. Just change author role to yours. Feb 21, 2020 at 20:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.