Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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
1  
Duplicate question on SE. –  dalbaeb May 6 '13 at 14:54
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.