Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Extending Roles via Plugin
<?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
*/
register_activation_hook(__FILE__, function()
{
// Make private posts and pages available to subscribers
$subRole = get_role( 'subscriber' );
$subRole->add_cap( 'read_private_posts' );
$subRole->add_cap( 'read_private_pages' );
});
register_deactivation_hook(__FILE__, function()
{
// Make private posts and pages unavailable to subscribers
$subRole = get_role( 'subscriber' );
$subRole->remove_cap( 'read_private_posts' );
$subRole->remove_cap( 'read_private_pages' );
});
@goatboy91587

This comment has been minimized.

Copy link
Owner Author

goatboy91587 commented Jun 10, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.