As you already know, my Private Content Plugin works fine with WordPress built-in standard roles. Sometimes a user asks for more information on how the plugin works with custom roles. Let’s see that in this post.

The form of the shortcode is the following:

[private role="author"]Text for Authors[/private]

This shortcode will show the text “Text for Authors” to these roles: Administrators, Editors, and Authors, because Authors is a role lower than the two others according to this list:

  • Administrator
  • Editor
  • Author
  • Contributor
  • Subscriber

As you know, the Private Content plugin can show a text to the intended role only. So, for example, we can write a note that only Editors can see:

[private role="editor-only"]Text for Editors only[/private]

Now, let’s say that we have a custom role, for example, “Friends”, and we want to show them some notes in our posts. In this case, we cannot use the following form:

[private role="friends"]Text for Friends[/private]

since isfriends not a standard WordPress role. In this case, we must pick up one of the standard WordPress roles and assign it one of the capabilities defined by the Private Content plugin. These capabilities are:

  • read_ubn_editor_notes
  • read_ubn_author_notes
  • read_ubn_contributor_notes
  • read_ubn_subscriber_notes

Mapping one of the capabilities to one WordPress role is easy with a plugin like Members or Capability Manager Enhanced.

Let’s say we decide that Friends can read notes for Editors. Using one of those plugins, assign read_ubn_editor_notes capability to the Friends role. Now Friends can read the notes for Editors only. Note the difference: now Friends can read notes marked with the option role="editor-only" while cannot read notes marked simply as role="editor".

I hope that things are clearer now. Someone asked why the plugin hasn’t an internal management of roles and capabilities. The answer is that the plugin was developed to remain simple. It was created to give a simple way to show some text to some users while hiding it from others. Adding more features will require a total reorganization of the plugin, and this is beyond the scope of its development.

Photo courtesy: geralt, Untitled, CC0 Public Domain.

Published by aldolat

A WordPress fanatic.