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'm using a custom post type to let contributors have a personal page on the site. Any time a user registers to my site a script creates a custom type post that has the registering user as author. To moderate users entries this post is pubblished by an editor.

I would like users (contributors) to be: - uncapable to add other posts of this custom type - capable to edit the already pubblished post they are author of - their changements must be approved by an editor before being pubblished

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

is there a way to do that?

share|improve this question
add comment

3 Answers 3

up vote 3 down vote accepted

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;
}
share|improve this answer
add comment

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');
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'] == "YOUR_CUSTOM_TYPE" ){ 
        if ($data['post_status'] = "publish"){
            $data['post_status'] = "pending";
        }
    }
    return $data;
}

and change YOUR_CUSTOM_TYPE to your custom post type name.

share|improve this answer
    
I'm already using Role Editor and i've set up the capabilities as you suggested, but the only thing changing is that the users has an additional checkbox right above the "pubblish" button asking to "save as pending revision". The problem is that i do not want the user to decide wether pubblish or not, they just shouldn't be able to pubblish but just save as pending revision. –  bluantinoo May 17 '11 at 15:01
    
If you set up correctly then they just can't publish. –  Bainternet May 17 '11 at 15:13
    
i've tried but maybe there's something I do not understand. This is a shot of my capabilities settings for the role I want to manage. As you can see hilighted, i've already set capability to edit_mycustomposttype but no pubblish_mycustomposttype. but still my users are able to pubblish edits... –  bluantinoo May 18 '11 at 13:52
    
OK i see what you mean, they can publish edits, that's just how wordpress works, but if you want to force re approval i updated my answer and added a function which saves the post as a draft if the user is not an admin. –  Bainternet May 18 '11 at 17:54
    
1) is it just a copy paste in functions.php? 2) do this function create a new revision or just set as pending the edited pubblished? –  bluantinoo May 18 '11 at 18:50
show 1 more comment

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

share|improve this answer
add comment

Your Answer

 
discard

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

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