开发者

Wordpress - Allow a userclass to save a page as a draft - but not publish w/o admin approval

I want to make a user class that can edit pages, and save them as a draft without being able to publish it. An admin would have to go in and publish the draft once they approve it.

The idea is similar to TDO Mini Forms except this will be done wit开发者_运维百科hin the Wordpress admin panel, not be a form, and they must be a registered user in a specific class to do this.

Thanks!


Install the Members Plugin, create a role for these users (or reuse the author role) and do not give them the publish_posts capability.

Here is a screenshot of how I handle this case on one of my clients site:

Wordpress - Allow a userclass to save a page as a draft - but not publish w/o admin approval

Update

To forbid publishing of edits you have to hook into the action transition_post_status and watch for changes. This actions tells you the old and the new post status and the post id:

add_action('transition_post_status', 'my_watcher', 10, 3);

function my_watcher($new_status, $old_status, $postid)
{
    // Get post content etc.
    $post = &get_post( $postid );

    // Compare the content and/or the status, do something.
}

In my case, this was overelaborate, plus we were afraid, users would feel patronized too much. I just made a dashboard widget¹ to list all changes for admins an editors. Now the users see their edits immediately live. The editors clean things up if needed. Works great. The users learn how to make good edits, that aren’t touched again, and the work for the editors declines over time. :)

¹ Be aware: All text strings are in German, you may have to edit them. I didn’t had the time for I18n, sorry.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜