All new user posts receive the status "Approved" and must be published by the administrator. But, after the post is published, the user can safely change it.

How to make so that after editing the record again was "On Approval" ?

    2 answers 2

    Hang the hook on the "save_post" event, check the role of the record-editing (there is a good table of user rights to their roles http://codex.wordpress.org/Roles_and_Capabilities ). If the user is below the rank of the editor and the entry has the status "published", change the status of the entry to "pending" ("under approval").

     function my_func_on_save_post($post_id) { if (defined('DOING_AUTOSAVE') && DOING_AUTOSAVE) { return $post_id; } if (!current_user_can('edit_pages', $post_id) && get_post_status($post_id) == 'publish') { wp_update_post(array( 'ID' => $post_id, 'post_status' => 'pending' )); } } add_action('save_post', 'my_func_on_save_post'); 
    • Thank! Checked - everything works fine) - Den

    In the admin panel, in the edit post, in the right sidebar (at the very top), there is a "Publish" window. In it "Status". Point there "On approval" and save. enter image description here

    • This is yes, but I need this status to be set automatically, so that users cannot publish content on the site without pre - moderation - Den
    • Do you use any plugin? - Valery Emelyanov
    • What is the plugin for? While put in the admin panel, so that all posts from the authors go to "for approval", change the role of the authors a little bit. It would be better to resolve the issue without a plug-in, of course ... - Den
    • Check your question. As I understand it: ordinary users of the site can create records themselves without entering the admin area. And you want these records not to be published automatically, but rather to be approved, right? - Valery Emelyanov
    • This is already implemented using standard wordpress tools. (Entering the admin panel) - Den