I want to stop authors from being able to constantly edit posts that are already pending review from editors.

To clarify; I already have code in my theme that sets live posts to pending and that works fine...

function published_to_pending($post_id) {
  global $post;
  if (!is_object($post)) {
  if (get_current_user_role()=="author" && get_post_type()=="custompost" && $post->post_status=='publish') {
    // stop recursion call
    remove_action('save_post', 'published_to_pending');     
    // update the post, which calls save_post again
    wp_update_post(array('ID' => $post_id, 'post_status' => 'pending'));
    // re-hook this function back
    add_action('save_post', 'published_to_pending');
add_action('save_post', 'published_to_pending');

I found something very similar to what I want to do here: Allow Editors to edit pending posts but not draft ones but no matter how I modify that code I can't get it to have any effect at all in my own site.

Does anyone have any idea how this can be achieved because I'm pretty confident it is from other code samples I have seen and what I understand of WordPress role functionality.

1 Answer 1


I resolved this by adding checks via the "content_edit_pre" WP hook. I quickly check on the status of the post and if it is already pending I return the user back to the post listing page and then show an error.

// Redirect edit post page back to the list page when pending
add_action( 'content_edit_pre', 'my_check_status_before_editing');
function my_check_status_before_editing( $content, $post_id) {
  global $post;

  if( $post->post_type=="custom-post-type" && get_current_user_role()=="custom-user-type" ){    
       if ($post->post_status=="pending" ){
    return $content;

function get_current_user_role() {
    global $wp_roles;
    $current_user = wp_get_current_user();
    $roles = $current_user->roles;
    $role = array_shift($roles);
    return $role;

When the list page loads I have other code to check if there is a "msg" url param and I then display an appropriate msg via the admin_notices hook.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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