How to let contributors to create a new revision(draft) editing their published posts

I’m using a custom post type to let contributors have a personal page on the site.

Any time a user registers on my site a script creates a custom type post that has the registering user as the author.

To moderate users’ entries this post is published by an editor.

I would like users (contributors) to be:

  • unable to add other posts of this custom type;
  • able to edit the already published post they are the author of;
  • and their changes must be approved by an editor before being published.

I’m using User Role Editor to manage roles and capabilities.

Is there a way to do that?

Answers:

Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.

Method 1

Using Role editor or role scope you can set contributors to edit you custom post type but not publish so every change will be set as draft until approval, and to limit the creation of new posts of your custom post type you can use my plugin Bainternet Posts Creation Limits

Update

To force re approval of edits add this code

add_filter( 'wp_insert_post_data', 're_aprove', '99', 2 );
function re_aprove( $data, $postarr ) {
    //check if current user is not admin
    if ( ! current_user_can( 'manage_options' ) && 'YOUR_CUSTOM_TYPE' === $postarr['post_type'] ) {
        if ( 'publish' === $data['post_status'] ) {
            $data['post_status'] = 'pending';
        }
    }
    return $data;
}

and change YOUR_CUSTOM_TYPE to your custom post type name.

Method 2

Mine didn’t work until I added the ’99’ , 2); to the end of the add_filter.

Here is the reference as to why: http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_insert_post_data

add_filter('wp_insert_post_data','re_aprove', '99', 2);
function re_aprove( $data , $postarr ){
    global $current_user;
    get_currentuserinfo();
    //check if current user is not admin
    if (!current_user_can('manage_options') && $postarr['post_type'] == "candy-item" ){ 
        if ($data['post_status'] = "publish"){
            $data['post_status'] = "pending";
        }
    }
    return $data;
}

Method 3

finally i’ve solved using Revisionary plugin,
http://wordpress.org/extend/plugins/revisionary/
it’s used to do exacly what I ask in the subject title

for more detailed control over capabilities (with revisionary already integrated) there is Role Scoper http://wordpress.org/extend/plugins/role-scoper/

the first one is really easy to setup and use
the second needs a lot more practice, userinterface it’s a bit confusing, but it’s really powerful


All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments