If you need to change one or two capabilities, it’s relatively easy to do so with a few lines of code in a plugin or your theme functions file. For example, if we wanted to allow any logged-in user to view our private posts and pages, we would need to grant them two additional capabilities.
<?php // allow subscribers to view private posts and pages $PrivateRole = get_role('subscriber'); $PrivateRole -> add_cap('read_private_pages'); $PrivateRole -> add_cap('read_private_posts'); ?>
The first line fetches the existing subscriber role (as an object) and assigns to it a variable. In the next two lines, we add the capabilities to read private posts and pages to our variable. That’s it! Any subscribers can now read your private content — and so can authors and contributors, whose roles include all the capabilities of subscribers. (Remember that editors and administrators already had these particular capabilities.)
Adding capabilities by hand, one at a time, will be a pain if you need to make a lot of changes. If that’s the case, I recommend Justin Tadlock’s Members plugin, which provides an elegant user interface for modifying roles, and also includes some great features for managing content permissions.
Ben says
Totally worked great! Thanks so much!!!