User based content restriction

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.


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.


Download the .zip file and place it in the plugins folder, activate.


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.


Anyone can see the post Not restricted or just Subscribers and above roles Subscribers only


More testing for the plugin and the framework and then another extension.