User based content restriction
July 8, 2015
First extension of the content restriction framework is up.
User Roles based restriction
As announced in an earlier post I've developed a first extension to the theAverageDev Restricted Content plugin and pushed it to GitHub.
I've gone for a first walking skeleton to allow me some testing of the framework and am satisfied with the little amount of code required to do so.
The following paragraphs are taken from the readme file.
Requirements
This plugin is an extension of the theAverageDev Restricted Content plugin and to render the content restriction meta box the plugin will use Custom Meta Boxes 2 so that's another requirement.
Installing
Download the .zip
file and place it in the plugins folder, activate.
Configuring
The plugin is meant for developers and does not come with a management UI users can use (beside the one for restricting the access). By default the plugin will apply user role based content restriction to posts and pages (post
and page
post types); to extend the plugin to more post types use the filter:
add_filter( 'urcr_restricted_post_types', 'myplugin_restricted_post_types' );
function myplugin_restricted_post_types(array $restricted_post_types){
$restricted_post_types[] = 'custom_post_type_1';
$restricted_post_types[] = 'custom_post_type_2';
return $restricted_post_types;
}
Anyone able to edit a post type will be able to set which user roles will be able to access it.
Screenshots
Anyone can see the post [](http://theaveragedev.local/wordpress/wp-content/uploads/2015/07/2015-07-08-at-18.34.png) or just Subscribers and above roles [
](http://theaveragedev.local/wordpress/wp-content/uploads/2015/07/2015-07-08-at-18.35.png)
Next
More testing for the plugin and the framework and then another extension.