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 would like to prevent users from one specific role from publishing directly their articles. Only administrators should be able to approve these. The only choice they would ever have is to put their articles as pending or draft. Any other roles may publish if they want. Is there a way to do so without any plugin and without having to dig too deep into the code?

Thank you

share|improve this question

1 Answer 1

up vote 1 down vote accepted

The following code can go in the functions.php file of your theme. However, this kind of operation should not really be bound to a theme. Changing themes would allow the users with your specific role to publish again. Therefore, just put the code in simple plugin.

<?php
/**
 * Plugin Name: My specific roles and capabilities
 * Plugin URI:  http://wordpress.stackexchange.com/questions/71841/pending-status-by-default-for-a-specific-role/71843
 */

$role = get_role('specific-role'); // Pick your role

if ( ! empty($role))
{
    $role->remove_cap('publish_posts');
}

See codex: get_role() and publish_posts.

share|improve this answer
    
Thank you, it's perfect and I will accept the answer. One thing though: I keep having the "publish" button. How can I have a button which reflects the "pending" status instead? –  Bachir Messaouri Nov 7 '12 at 14:41
    
Did you change "specific-role" with your actual role? The submit button should say "Submit for Review" now. –  Geert Nov 7 '12 at 14:45
    
Actually it's ok now. Yes I did and it worked but for some reason I had to reinit my browser in order for the button to change the status. Don't get it as it's a server thing but it worked. Thank you very much as I thought I would have to spend the night on it. –  Bachir Messaouri Nov 7 '12 at 14:54

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.