Skip to content

Instantly share code, notes, and snippets.


Brett Widmann goatboy91587

View GitHub Profile
goatboy91587 / role-extender.php
Last active Jun 10, 2019
Extending Roles via Plugin
View role-extender.php
* Plugin Name: Allow Subscribers to Read Private Content
* Plugin URI:
* Description: A plugin that allows subscribers to read private posts and pages
* Version: 1.0
* Author: Brett Widmann
* Author URI:
goatboy91587 / add-cap-functions.php
Created Jun 9, 2019
Adding Capabilities to Roles in WordPress via Hook
View add-cap-functions.php
// Make private posts and pages available to subscribers
function subs_read_private_content(){
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
add_action( 'init', 'subs_read_private_content' );