Decide who edits legal pages and who changes the plugin settings
TermsFeed AutoTerms controls access with 10 capabilities of its own, the plugin roles it creates, and the WordPress capabilities manage_options and unfiltered_html. The legal page screens follow the 10 capabilities. The settings screens need manage_options, or edit_wpautoterms_pages together with unfiltered_html, and every field that holds code or HTML needs unfiltered_html to save new code.
Check access in your code with current_user_can(), never by reading a role.
The legal page capabilities
The post type wpautoterms_page maps the WordPress meta capabilities, such as edit_post and delete_post, onto these 10, as the page post type maps them onto edit_pages.
| Capability | Allows |
|---|---|
edit_wpautoterms_pages |
Edit your own legal pages, open All Legal Pages and Add Legal Page, and open the Dashboard and Help screens |
edit_others_wpautoterms_pages |
Edit legal pages that other users wrote |
edit_private_wpautoterms_pages |
Edit private legal pages |
edit_published_wpautoterms_pages |
Edit published legal pages |
read_private_wpautoterms_pages |
Read private legal pages |
delete_wpautoterms_pages |
Delete your own legal pages |
delete_others_wpautoterms_pages |
Delete legal pages that other users wrote |
delete_private_wpautoterms_pages |
Delete private legal pages |
delete_published_wpautoterms_pages |
Delete published legal pages |
publish_wpautoterms_pages |
Publish legal pages |
A Super Admin, and any user with manage_options, a site Administrator on a network included, passes every check about legal pages without holding the 10 capabilities. current_user_can( 'edit_wpautoterms_pages' ) therefore returns true for an Administrator. The example adds a "Legal Pages" item, linked to All Legal Pages, to the admin toolbar for every user who edits legal pages, Administrators included.
add_action(
'admin_bar_menu',
function ( $wp_admin_bar ) {
if ( ! current_user_can( 'edit_wpautoterms_pages' ) ) {
return;
}
$wp_admin_bar->add_node(
array(
'id' => 'mytheme-legal-pages',
'title' => esc_html__( 'Legal Pages', 'mytheme' ),
'href' => admin_url( 'edit.php?post_type=wpautoterms_page' ),
)
);
},
100
);
The roles the plugin creates
The second role exists only on sites that have the WordPress Editor role.
| Role | Display name | Capabilities |
|---|---|---|
manage_wpautoterms_pages |
WPAutoTerms Pages Editor (additional) | The 10 legal page capabilities only, meant as a second role beside the main role a user holds |
manage_wpautoterms_pages_editor |
Editor + WPAutoTerms Pages Editor | Every capability the Editor role held when the plugin created the role, plus the 10 legal page capabilities |
A user whose only role is "WPAutoTerms Pages Editor (additional)" lacks read, so WordPress sends that user to the home page after login and refuses the Dashboard and Profile screens. Give the role only beside a main role such as Author or Contributor.
Each role keeps the capabilities it received at creation, so a later change to the Editor role does not reach "Editor + WPAutoTerms Pages Editor". Change a role afterward with a role editor plugin or with WP_Role::add_cap() and WP_Role::remove_cap().
Deleting the plugin removes the plugin roles on every site: users of "Editor + WPAutoTerms Pages Editor" become Editors, and users of the additional role lose the legal page capabilities. Read every step of removal in Install the TermsFeed AutoTerms Plugin on WordPress.
Who opens and saves each screen the plugin adds
A user without the access in a settings row does not see a menu item for that screen.
| Screen | Opens and saves with |
|---|---|
| All Legal Pages, Add Legal Page, the legal page editor | edit_wpautoterms_pages, plus the capability that matches the post (published, private, or written by another user) |
| Dashboard, Help | edit_wpautoterms_pages |
| Compliance Kits, every kit screen, the "Enable" and "Disable" buttons | manage_options, or edit_wpautoterms_pages with unfiltered_html |
| The Customization, Vendor Scripts, and Configuration Parameters tabs, and the Preview of the Cookie Consent kit | manage_options, or edit_wpautoterms_pages with unfiltered_html |
| Settings (General and Advanced tabs), Legacy Auto TOS & PP | manage_options, or edit_wpautoterms_pages with unfiltered_html |
The common roles on a single site get this access.
- Administrator. An Administrator has
manage_optionsand opens every screen the plugin adds. - Editor + WPAutoTerms Pages Editor. The Editor role holds
unfiltered_htmlon a single site, so this user opens the legal pages, Compliance Kits, and Settings. - Author with the additional role. An Author lacks
unfiltered_html, so this user edits legal pages and does not see the Compliance Kits or Settings item. - Editor without a plugin role. The Editor does not see the TermsFeed menu.
On a multisite network only a Super Admin holds unfiltered_html, so a site Administrator opens every settings screen through manage_options but does not save new code. An "Editor + WPAutoTerms Pages Editor" user sees the legal pages only. Find each symptom of a code field that does not save in Code or HTML Not Saving in WordPress. Set up a network with WordPress Multisite Legal Pages.
Where each role the plugin creates is assigned
The user profile screen offers a single role per user, so the additional role needs WP-CLI or a role editor plugin.
| Role | Assigned with | WP-CLI command, for the user login jane |
|---|---|---|
manage_wpautoterms_pages_editor |
The Role select of the user profile, or WP-CLI | wp user set-role jane manage_wpautoterms_pages_editor |
manage_wpautoterms_pages |
WP-CLI or a role editor plugin, as a second role | wp user add-role jane manage_wpautoterms_pages |
Both commands apply from the next page the user loads. Give an Editor access to legal pages, step by step, with Edit and Publish WordPress Legal Pages.