Skip to content

Instantly share code, notes, and snippets.

Avatar

Brett Widmann goatboy91587

View GitHub Profile
@goatboy91587
goatboy91587 / role-extender.php
Last active Jun 10, 2019
Extending Roles via Plugin
View role-extender.php
<?php
/**
* Plugin Name: Allow Subscribers to Read Private Content
* Plugin URI: https://brettwidmann.com
* Description: A plugin that allows subscribers to read private posts and pages
* Version: 1.0
* Author: Brett Widmann
* Author URI: https://brettwidmann.com
*/
@goatboy91587
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' );
You can’t perform that action at this time.