BTW The pages that I want to protect are custom post types: articles for a knowledge base. I’m using MinervaKB as knowledge base plugin, and as far as I know, the custom post type is ‘kb’.
Hey Marc,
The best solution I can think of would be to assign the user to a new role which has all capabilities of an administrator, then create a new capability for administrators only. Perhaps something like manage_options_and_kb_posts
.
Once the new role and capability are created you would then use the postlockdown_admin_capability
filter to use the new capability rather than the default manage_options
:
add_filter('postlockdown_admin_capability', function() {
return 'manage_options_and_kb_posts';
});
I have used the User Role Editor plugin for managing user roles and capabilities in the past and it seemed to work pretty well.
Let me know how you get on!
Hi Andy, thnx for the quick reply, mate!
I’m not a coder, so your solution is just a bit too complicated for me. But no worries, I’ve posted my question in a Facebook group and I got this suggestion: https://pastebin.com/DUPCWBPa
It seems to work quite nice, though it gives some warnings/messages about autosaved versions of the page. So I changed the code a bit.
Instead of:
remove_post_type_support( get_post_type( $post_id ), 'editor' );
I’m using:
echo "<script type='text/javascript'>alert('Dit is een template: niet wijzigen!');</script>";
Now a popup appears telling the user that the page is a template and should not be edited. Not sure if it’s the best way to create a popup, but it works, and does not give the autosave message.
Suggestions are appreciated, but for now it kind of works, so all fine 😉