original document: 10 July 2008
revision: 3 November 2008
This document contains Topical commentary to orient an experienced WordPress blog administrator to the new permission controls offered by Role Scoper. Those uninterested in this discussion may skip to step-by-step instructions in the How-to Guide. This document is a work in progress which will be expanded and updated periodically.
For a general overview of Role Scoper’s motives and screen shots which may provide a helpful accompaniment, see the following online document: http://agapetry.net/news/introducing-role-scoper/
Section 1: Glossary and Commentary
Section 2: How-to Guide
Section 3: Customizations and Extensions
Role Scoper is a comprehensive drop-in replacement for capability enforcement and administration in WordPress. Assign reading, editing or administration roles to users or groups on a page-specific, category-specific or other content-specific basis.
After activating Role Scoper, you will find two new utility links on the right next to “Settings”: Roles and Groups. Most of Role Scoper’s settings are accessed through the “Roles” or “Groups” links.
“Groups” pertains to the definition of User Groups, and to role assignments for those groups (see “User Groups” below. The role assignment portion of the “Groups” tab is therefore a mirror of corresponding role assignment links on the “Roles” tab which pertain to individual users.Those wishing only to assign or restrict access to an individual post or page may go straight to the WordPress post/page editor interface and look for the new “Readers”, “Contributors” and “Editors” tabs.
By default, Wordpress roles specify capabilities that a user has blog-wide. Pages and Posts can be marked private. If a user’s role includes the read_private_pages capability, all private pages are readable to them. Otherwise none are. The same is true for editing or publishing capabilities - a user can edit all posts made by other users, or none of them.
Role Scoper allows you to assign roles in any of three scopes: blog-wide (Blog scope), category-wide (Section scope) or for a specific post/page (Object scope). To reduce confusions, the generic names “section” and "object" are not generally used in the User Interface or in this documentation. However, a section can consist of some custom taxonomy other than “category”, and may or may not use the WP term_taxonomy schema. Likewise, Role Scoper can be configured to control permissions for "objects" other than posts and pages. In the future, other plugins may use Role Scoper API to define sections such as forums, calendars or galleries.
When some read or edit operation is requested, Role Scoper filters the request and grants permission if the user has a qualifying role in any scope:
Blog scope or Section scope or Object scope.
Category roles, as an instance of “Section Roles”, are assigned on the WP Admin -> Roles -> Category page. Users and/or Groups may receive a Category Role assignment. Each Category has a separate set of role checkboxes. Note that whether assigning or removing role assignments, you must check all the users/groups and all the roles being modified. The dropdown list next to the “Update” button determine what effect the update has.
When assigning Category Roles, you can choose whether to assign to the selected categories only, to the selected and all subcategories (present or future), or to subcategories only.
Post Roles and Page Roles are instances of “Object Roles”. They may be assigned via new tabs on the WP post / page edit interface - “Readers”, “Editors”, etc. When selecting users or groups for page role assignment, note that the normal checkboxes assign the role to current page, whereas the braced {[]} checkbox assigns the role to all subpages (present or future).
A role assignment grants a user or group capabilities which they may not already have. When you assign several users the Post Editor role in “Category A”, you are allowing them to edit “Category A” posts on the basis of Category Role. Some may already qualify based on their general (blog-wide) WordPress role, others may not.
However, one user’s role assignment does not reduce access for any other users. To deny some users access to “Category A” even though their General Role qualifies, you must specify a Category Restriction. There is a separate setting for each Role in each Category. For Category A, if the Post Reader role is restricted, then users with a general Wordpress role of Post Reader (which includes anonymous users) cannot read Category A posts unless they have a Category Role or Post Role assignment. Users with a different general role which also contains the required capabilities will not be excluded.
Another way of describing Restrictions is that they allow you to selectively remove one or more qualifying clauses from the {General Role OR Category Role OR Post/Page Role} formula.
As stated above, categories can be configured such that a user’s General Role is ignored - and a qualifying Category Role or Post/Page role assignment is required. Likewise, individual posts and pages can be configured such that General Role and Category Roles are ignored. These Post/Page Restrictions can be used to narrow read or edit access.
Limiting read access to a fixed set of users is a three-step operation in the WordPress post edit interface.
Any General Role, Category Role or Post/Page role assignment can be applied to individual users or to a group of users. If your user base includes subsets of user who commonly get the same role assignments, consider defining those users as members of a Group.
In addition to custom-defined user groups, you may find it convenient to assign some Category Role or Post/Page Role to all users who have a certain WordPress-defined Role. You will find these metagroups (labeled as [WP Editor], [WP Author], etc.) alongside the custom-defined groups in role assignment interfaces.
Wordpress defines “private” posts and pages as those which require a corresponding read_private capability, usually possessed only by Administrators, Editors, and by the content author. Most significantly, the content is hidden from anonymous users.
For the purpose of limiting read access, Role Scoper Restrictions can be used as an equivalent. If a post’s categories, or the post itself, Restrict the Post Reader role, the post is effectively private regardless of the WP private status. Likewise, Category Role or Post/Page Role assignments can enable access to a “private” post or page as long as the assigned role includes the corresponding read_private capability.
Despite the potential equivalence stated above, setting sensitive posts or pages to WP “private” is still the recommended approach. This will ensure that if Role Scoper is accidentally disabled, content is not revealed inappropriately. In the future, Role Scoper may automatically set posts/pages to private when a corresponding Role Scoper setting is made. Due to technical difficulties, you must currently achieve that extra safeguard manually.
In Wordpress jargon, Roles contain Capabilities. Wordpress comes with a default set of Roles - Administrator, Editor, Author, Contributor and Subscriber. Those default role definitions are sensible and sufficient for most WP installations. The adventuresome can use the Role Manager plugin to add or remove capabilities from any role, perhaps to account for new capabilities defined by some other plugin. The intent is that for any user, there is one role definition which comprehensively describes every capability the user has, for any object type which exists within the blog. Every user has one general role.
By default, Role Scoper takes a different approach - the “RS” role type. Each object type has a different set of role definitions. So, for posts, there are “Post Reader, Private Post Reader, Post Author, Post Editor” role definitions. Likewise for pages and, potentially, for other plugin-defined object types which choose to support RS role definitions.
The upshot of this is that instead of defining a modified “Author” role which also includes the “edit_pages” capability, you just assign the “Page Author” role where desired. Instead of just assigning one comprehensive WP-defined role, you can select a pertinent RS-defined role separately for each object type.
If for any reason you must apply WP-defined roles as Category Roles or Post/Page Roles, simply go to WP Admin > Roles > Roles and change the Role Type dropdown to “WP”.
Another happy side effect of “RS” role types is the ease with which plugins can enable users to assign newly-defined capabilities. Role Scoper introduces the “create_child_pages” capability. This capability enables a user to select the corresponding page as “Page Parent”. Otherwise a page is unavailable as parent unless the user can edit it. The new RS-defined “Page Associate” contains “create_child_pages”, making it one step up from Page Reader. This useful role distinction would have been difficult to provide if each blog administrator was required to manually merge the capability into existing WP roles.
Note that Role Scoper will not allow a page to be published with a “Main Page” parent unless the user has the blog-wide edit_published_ pages capability. Although WordPress doesn't provide a means to remove “Main Page” from the dropdown, attempts by unqualified users to publish a new page with “Main Page” parent will result in “draft” status. Attempts to modify an existing page from non-Main to Main (or from Main to non-Main) Page Parent will revert the page back to the previous stored Page Parent.
(note: this section is a work in progress which does not yet fully address Editing Roles)
Groups created in this manner will be available for role assignment in the following procedures.
Role Scoper can be configured to hide or reveal posts regardless of any WP-defined “private” status. The procedures below are sufficient to set post visibility. However, there are three reasons you might still choose to set the WP “private” status:
The following procedures apply regardless of whether you check the “keep this post private” box:
The post will now be hidden from WP Subscribers who are not selected in this “Readers” tab. If the post must also be hidden from WP Contributors, set the “Restrict” checkbox in the “Contributors” tab. To hide it from WP Authors and Editors, set the “Restrict” checkbox in the “Editors” tab. In Role Scoper lingo, the post now Restricts the checked roles.
If it's convenient to manage each hidden post/page with the above procedures, that's all you need to know. If access control by category is desirable, read on.
Note that if a Post Restriction is not set for Readers, read access to it will be granted if:
So you cannot hide a post just by assigning it to an additional “hidden” category. If individual posts don't restrict the Readers role, they will be readable if any of their categories are readable to the user. If your categorization and post restriction goals demand the “readable cat + hidden cat = hidden post” formula, you'll be frustrated with this plugin. But here are some suggestions for making the Role Scoper model work with your existing categories:
There are two pieces: granting access and restricting access, and two basic ways to achieve the desired access and restrictions:
You can also use some combination of the two. Where possible simplify your life by setting your users as WordPress subscribers, then following the first Role Scoper configuration procedure below. This also provides the greatest security, since those users will default to zero editing ability if Role Scoper is accidentally deactivated or otherwise disabled.
If some users need to retain a higher WordPress role but still be limited in posting categories, you will also need to define that extra restriction as follows:
Now Contributor and Authors (and editors, if you restricted that role) will not be able to post or edit in any category unless you assign them a Category Role for it, as explained for UserA above. Note that the "DEFAULTS" setting applies the restriction to all existing and future categories (unless one is manually unrestricted). To restrict fewer categories, select desired restrictions for each category instead.
Note that if you also assign this user a Role Scoper General Role of Page Author, they will be able to create subpages off their member page, but not off any other pages:
OR, if you want all subscribers to have this ability:
(note: this section will be expanded in future revisions)
By default, Role Scoper hides content for which users lack a sufficient role assignment. You can also apply a teaser by activating that option in the Role Scoper options page at WP Admin > Roles > Roles.
Other options on the Roles > Options page pertain primarily to customizations of the Role Scoper for future plugin-defined data sources. Most users can safely leave the default settings. The settings available there do contains descriptive captions.
To support customized markup of restricted and/or currently hidden posts, Role Scoper provides the following template functions for use in themes:
is_restricted_rs( );
is_teaser_rs(
);
note:
If
calling these functions outside the WP loop, you should pass post ID as
the
first function argument. Otherwise just call as stated above.
Other plugins may define their own data sources, taxonomies (WP term_taxonomy or custom tables), capabilities and roles. See defaults_rs.php and role-scoper_main.php for example hook usage. Details will be provided in later versions of this document.
A current version of this document is available online at