Private Content

Fork me on GitHub

This plugin provides a shortcode to display a portion of a post content only to users of a specific role. For example, you can show the hidden text to Editors or to Authors or to any other WordPress role.

Please, note that an Administrator can read an Editor private content or a Subscriber private content, and so on. Same thing for Editor, Author, Contributor, and Subscriber: a higher role can read a lower role content.

Also you can show the hidden text only to a certain role. For example, you can mark a text as visible only to Contributors and hide it to higher roles, such as Administrators or Editors and so on.

As of version 3.0 you can mark a text as visible only to a certain user, using his login name.

As of version 4.0 you can mark a text as visible to multiple users, using their login names comma separated.

Utilizzo

Display this text only to Administrators:

[private role="administrator"]Text for Administrators[/private]

Display this text only to Administrators and Editors:

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

Display this text only to Administrators, Editors, and Authors:

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

Display this text only to Administrators, Editors, Authors, and Contributors:

[private role="contributor"]Text for Contributor[/private]

Display this text only to Administrators, Editors, Authors, Contributors, and Subscribers:

[private role="subscriber"]Text for Subscribers[/private]

Text only for specific roles

If you want to show a note only to a certain role, you have to use a <role>-only option. In this way, for example, an Administrator or an Editor (roles higher than Author) cannot read a note only for Authors.

These are all the cases:

[private role="editor-only"]Text for Editors only[/private]
[private role="author-only"]Text for Authors only[/private]
[private role="contributor-only"]Text for Contributors only[/private]
[private role="subscriber-only"]Text for Subscribers only[/private]
[private role="visitor-only"]Text for Visitors only[/private]

Text only for a specific user

In the case you want to show a text only to a specific user, assign none to role and a login name to recipient:

[private role="none" recipient="login-name"]Text for a specific user only[/private]

Change login-name with the correct login name of the target user.

You can use a comma separated list of usernames to target certain users:

[private role="none" recipient="login-name1, login-name2, login-name3"]Text for specific users only[/private]

Change login-name1, login-name2, and login-name3 with the correct login names of the target users.

Alternate text for non-targeted users

If you want to show an alternate text in case the reader can't read, you can use:

[private role="author" alt="You have not rights to read this."]Text for authors only[/private]

Please, take note that the alternate text, if defined, is always publicly displayed.

The alternate text can contain some HTML tags. The list is:

  • b or strong for bold text;
  • em or i for italic text;
  • a for links, with href and title included. For href and title do not use double quote, but single quote.

Container for the text

Starting from version 2.4, the user can choose the container element for the text:

  • p is the default value;
  • div is another option. This element allows you use HTML elements like lists, headings, and more.
  • span is the final option. This element allows you to add private content inline.

Usage:

[private container="div"]This is the text[/private]
I met with a friend[private container="span"] (Jenny, from ninth grade)[/private] for lunch.

Standard WordPress user roles

WordPress roles in descending order:

  • Amministratore
  • Editor
  • Autore
  • Contributore
  • Iscritto

Donate





About this plugin

This plugin provides a shortcode to display a portion of a post content only to users of a specific role. For example, you can show the hidden text to Editors or to Authors or to any other WordPress role.

Please, note that an Administrator can read an Editor private content or a Subscriber private content, and so on. Same thing for Editor, Author, Contributor, and Subscriber: a higher role can read a lower role content.

Also you can show the hidden text only to a certain role. For example, you can mark a text as visible only to Contributors and hide it to higher roles, such as Administrators or Editors and so on.

As of version 3.0 you can mark a text as visible only to a certain user, using his login name.

As of version 4.0 you can mark a text as visible to multiple users, using their login names comma separated.

Utilizzo

Display this text only to Administrators:

[private role="administrator"]Text for Administrators[/private]

Display this text only to Administrators and Editors:

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

Display this text only to Administrators, Editors, and Authors:

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

Display this text only to Administrators, Editors, Authors, and Contributors:

[private role="contributor"]Text for Contributor[/private]

Display this text only to Administrators, Editors, Authors, Contributors, and Subscribers:

[private role="subscriber"]Text for Subscribers[/private]

Text only for specific roles

If you want to show a note only to a certain role, you have to use a <role>-only option. In this way, for example, an Administrator or an Editor (roles higher than Author) cannot read a note only for Authors.

These are all the cases:

[private role="editor-only"]Text for Editors only[/private]
[private role="author-only"]Text for Authors only[/private]
[private role="contributor-only"]Text for Contributors only[/private]
[private role="subscriber-only"]Text for Subscribers only[/private]
[private role="visitor-only"]Text for Visitors only[/private]

Text only for a specific user

In the case you want to show a text only to a specific user, assign none to role and a login name to recipient:

[private role="none" recipient="login-name"]Text for a specific user only[/private]

Change login-name with the correct login name of the target user.

You can use a comma separated list of usernames to target certain users:

[private role="none" recipient="login-name1, login-name2, login-name3"]Text for specific users only[/private]

Change login-name1, login-name2, and login-name3 with the correct login names of the target users.

Alternate text for non-targeted users

If you want to show an alternate text in case the reader can't read, you can use:

[private role="author" alt="You have not rights to read this."]Text for authors only[/private]

Please, take note that the alternate text, if defined, is always publicly displayed.

The alternate text can contain some HTML tags. The list is:

  • b or strong for bold text;
  • em or i for italic text;
  • a for links, with href and title included. For href and title do not use double quote, but single quote.

Container for the text

Starting from version 2.4, the user can choose the container element for the text:

  • p is the default value;
  • div is another option. This element allows you use HTML elements like lists, headings, and more.
  • span is the final option. This element allows you to add private content inline.

Usage:

[private container="div"]This is the text[/private]
I met with a friend[private container="span"] (Jenny, from ninth grade)[/private] for lunch.

Standard WordPress user roles

WordPress roles in descending order:

  • Amministratore
  • Editor
  • Autore
  • Contributore
  • Iscritto
Name of the plugin: Private Content
Plugin version: 4.1
This plugin requires WordPress 3.0
Tested up to WordPress 4.7
Last updated: 26 novembre 2016 (2 settimane ago)
Compatibility: Unknown with WordPress 4.7
Tags: content, private
Downloaded: 22.133
Rating: 5 stars

Latest changes

  • NEW: added support for links in alternate text.

Download

You can get a copy from the page in the official repository: Private Content. This plugin has been downloaded 22.133 times.

Author

Author’s name: Aldo Latino
Profile on wordpress.org: Aldo Latino

Screenshots

  1. private-content screenshot 1

    At the center of the screen, the shortcode is used in the WordPress editor. The text inside the shortcode will be displayed only to Authors and above roles.

  2. private-content screenshot 2

    The shortcode in action. On the left, the text revealed to Administrators only; on the right, the page as seen by lower roles (Editors, Authors, etc., or simply readers).

Changelog

4.1

  • NEW: added support for links in alternate text.

4.0

  • NEW: Added support for multiple recipents.

3.0

  • NEW: Added option for a single user.
  • FIX: now, if the role is not correctly entered, the shortcode does not display anything.
  • Removed CSS class in the alternate text, in order to hide which type of users was the recipent of the text.

2.5

  • NEW: Added ability to use "span" as a container.
  • FIX: Removed shortcode execution in feed.

2.4

  • NEW: now it's possible to use a div container instead of p, thanks to a pull request of Matt.

2.3

  • FIX: Added styling option for the alternate text.
  • Added style to role-only alternate text.

2.2

  • NEW: now the plugin can show an alternate text if the reader hasn't the capability to read the text.

2.1

  • NEW: added the possibility to show a note only to Visitors (thanks to Jacki for the tip).

2.0

  • NEW: now you can show a note only to user of a specific role, hiding that note to higher roles.
  • Added uninstall.php to delete the new custom capabilities.

1.2

  • Now the inline style appears only if necessary.

1.1

  • Upon request, added the possibility to align the text left, right, centered and justified.

1.0

  • First release of the plugin.

Contributors

aldolat, specialk, thewanderingbrit.

Other Notes

Credits

Many thanks to:

Support

You can get support in this forum.

Donations

Say your “Thanks!” to the developer with a small donation.





6 pensieri riguardo “Private Content”

    1. I’m sorry for this, but I haven’t this framework to test it.

      If you use Genesis, you can ask in the framework’s forum for help. Then, it will be appreciated if you share here the solution for other users.

  1. Hello,

    How to do for displaying a portion of a post’s content only to users WITH NO specific role (visitors, non registred persons) with Private Content ? (would be very helpful)

    1. Good point! I’ve just added this feature and pushed up the new 2.1 version to the WordPress repository. Wait for the update notification or manually update it.

      Now you can use:

      [private role="visitor-only"]Text for Visitors only[/private]

      Thanks for the tip!

Lascia un commento

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *