How can I allow 'Authors' the ability to lock posts?

Hi, I have just purchased Lock Posts Plugin and it is not much good if only super-admins can operate it. I need to make other groups other than 'super admins' be able to to this - notably members of the 'Authors' group. Is it possible to add a capability using User Role Editor?

  • Vinod Dalvi

    Hi @Jason,

    You are welcome to the WPMU Dev community.

    You can achieve this by modifying plugin code.

    Just open lock-posts/lock-posts.php plugin file and make the following changes in it.

    Comment or Remove following code on line number 136

    if (!is_super_admin()) return;

    Comment or Remove following code on line numbers 148 and 149

    if ( !is_super_admin() )
    	return;

    On line number 183 replace the code with the following code.

    $last_edited_author_id = get_post_meta($_GET['post'], '_edit_last', true);
        if ( !is_super_admin() && $last_edited_author_id != get_current_user_id() && !empty( $_GET['action'] ) && 'edit' == $_GET['action'] && !empty( $_GET['post'] ) ) {

    On line number 174 remove the following check from if condition

    && is_super_admin()

    Best Regards,
    Vinod Dalvi

  • Jason

    OK, I've found it now thanks. I have tried your modification and it doesn't really do what is required. What I need it to do is as follows:

    1. A Student (a member of the Contributors group) creates a Post and when ready for submission to their tutor, marks the Post as 'For Tutor Review' as a custom status.
    2. The Tutor (a member of the Authors group) or the Editor (a member of the Editors group) is then able to lock it so that the student cannot change it from that point onwards.

    Using your modification, at the moment the Tutor (member of 'Authors' group) does not even see the lock posts option in the Post. The Editor (member of the 'Editors' group) does and is able to lock the post successfully. HOWEVER, after the post is locked, the Student is still able to access the 'Quick Edit' option under the Post where they can change the custom status and post category etc. and even Trash the Post!!! Surely this defeats the point of the plugin and the Post isn't 'Locked' at all? Can these issues be solved by modifying the code? If not, then I would like my money back. Thanks.

  • Vinod Dalvi

    Hi @Jason,

    OK, I've found it now thanks. I have tried your modification and it doesn't really do what is required. What I need it to do is as follows:

    You have a custom functionality requirement and it will need to develop custom code.

    You can consider hiring a developer from https://premium.wpmudev.org/wpmu-jobs/ WPMU DEV Job Board to develop it for you.

    Using your modification, at the moment the Tutor (member of 'Authors' group) does not even see the lock posts option in the Post.

    I think by 'Authors' group you are referring as Author role and author role can only publish and manage their own posts so lock posts option will not be available for others posts.

    If you want author to do this then you can achieve this by granting privileges to this role using any role manager plugin like
    http://wordpress.org/extend/plugins/user-role-editor/

    The Editor (member of the 'Editors' group) does and is able to lock the post successfully. HOWEVER, after the post is locked, the Student is still able to access the 'Quick Edit' option under the Post where they can change the custom status and post category etc. and even Trash the Post!!! Surely this defeats the point of the plugin and the Post isn't 'Locked' at all? Can these issues be solved by modifying the code? If not, then I would like my money back. Thanks.

    I have notified the developer to fix it in the plugin.

    In the meanwhile you can use the solution posted on the following thread.

    https://premium.wpmudev.org/forums/topic/would-be-great-to-hide-locked-pages-from-admin-when-using-lock-posts-plugin#post-514843

    For all payment related queries, you can contact our accounting and billing department using the following secured form.

    https://premium.wpmudev.org/contact/

    Kind Regards,
    Vinod Dalvi

  • Alex Furr

    Hi Jason,

    Sounds like you were trying to do what we needed to do. I've modified the code so it does what we need.
    You can now specify that individual site admins also have the option to lock posts - so typically an academic would be the site admin and students would be authors on the site. The modifications I've made allows the admin of the site (academic) to lock the post, but not the students (authors)

    Let me know if you want a copy and I'll send you the zip
    Alex

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.