WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am developing a Wordpress site with Edit Flow plugin, so I can create custom post statuses to manage author and contributor posts more easily.

So I have created custom post status and I've got following filter to restrict edit capabilities to that post. It is working fine, but the problem is that users (except admin) can't preview the post. Other users can still see the "Preview" link in dashboard post list, but if they click on it and go to post preview page (../post-with-custom-status/?preview=true) it says that post can't be found.

function restrict_edit_custom_status_posts( $allcaps, $cap, $args ) {

    // Bail out if we're not asking to edit a post ...
    if( 'edit_post' != $args[0]
        // ... or user is admin
        || !empty( $allcaps['manage_options'] )
        // ... or user already cannot edit the post
        || empty( $allcaps['edit_posts'] ))
        return $allcaps;

    // Load the post data:
    $post = get_post( $args[2] );

    // If post have custom status
    if( 'my_custom_status' == $post->post_status ) {
    // Then disallow editing
    $allcaps["edit_posts"] = FALSE;
        return $allcaps;

    return $allcaps;
add_filter( 'user_has_cap', restrict_edit_custom_status_posts10, 3 );

So is there any way that I can restrict edit capability, but allow preview?

share|improve this question
Duplicate question on SE. – montrealist May 6 '13 at 14:54

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.