WordPress.org

Ready to get started?Download WordPress

Plugin Directory

Eyes Only: User Access Shortcode

Show or hide any portion of post content based on usernames, user roles, capabilities, custom groups, or logged-in status.

Show or hide any portion of post content based on usernames, user roles, capabilities, custom groups, or logged-in status. Construct shortcodes manually or using a point and click UI.

Mini Update Log

  • v1.8.2 compat with WordPress 3.9
  • v1.8.1 fixed conflict with the Tabify Edit Screen plugin

  • v1.8 added new shortcode handlers for nesting eyesonly shortcodes. also added body classes for logged-in user roles and logged-in usernames.

  • v1.7.1 fixed bug with TinyMCE button where TinyMCE panel is used outside post/page editor.

  • v1.7 added multisite support for username multiselect; fixed bug with role/level dropdown in non-Mozilla browsers.

  • Lots of new features in v1.6, including smooth integration with Role Scoper and Press Permit, thanks to their author Kevin Behrens, who has also now joined the Eyes Only team. Two makes a team, right?

  • As of v1.5, has compatibility with BuddyPress and BBPress forums in conjunction with the bbPress2 shortcode whitelist plugin by Anton Channing.

  • As of v1.4, includes TinyMCE Shortcode Button with Shortcode Generator Modal, with options to restrict access to the Shortcode Button, and to determine its position on the TinyMCE panel.

  • As of v1.3, includes Options page, with options to restrict access to the Meta Box, and to prevent content being hidden from Administrators.

  • As of v1.2, includes Shortcode Generator Meta Box

  • See full changelog

The Shortcode

[eyesonly] [/eyesonly]

or

[eyesonlier] [/eyesonlier]

or

[eyesonliest] [/eyesonliest]

  • Required attributes: either logged="in|out" or level="anyrole, any_capability" or username="anyusername" or all three

  • Newly integrated attributes: rs_group="any_Role_Scoper_group(s)" or pp_group="any_Permit_Press_group(s)"

  • Optional attribute: hide="yes"

All shortcodes must include at least one of the three required attributes. In some cases, it makes sense to use all of them together.

  • The 'logged' attribute takes one of two values: 'in' or 'out'

  • The 'level' attribute takes any user role (including custom roles) or any capability (including custom capabilities). It can take multiple roles and/or capabilities, separated either by spaces or commas.

  • The 'username' attribute takes any userlogin (username), or multiple, separated either by spaces or commas.

  • The 'rs_group' and 'pp_group' attributes can take comma or space-separated lists just like the 'level' and 'username' attributes. If you have the latest versions of either Role Scoper or Press Permit activated, you'll get an extra menu in your shortcode generators to filter your content by those custom user groups. This attribute can also be used in combination with any of the others to fine tune your filtering.

  • The 'hide' attribute: By default, the shortcode will show the content only to the users specified by the 'username', 'level' or 'logged' attributes. Adding the 'hide' attribute will reverse that, and hide the content from the specified users. To hide content from the specified users, use hide=yes or hide=true.

Any other shortcode can be used inside this shortcode.

Examples

  • [eyesonly level="administrator, customrole, moderate_comments"] Any kind of content. [/eyesonly]
    This will show the content only to users with the 'administrator' role, the 'customrole' role, and the 'moderate_comments' capability.

  • [eyesonly hide="yes" logged="out" level="subscriber customrole"] Any kind of content. [/eyesonly]
    This will hide the content from all logged out users, and from anyone with the roles 'subscriber' or 'customrole'.

  • [eyesonly username="joebob, billyjean" level="administrator"] Your content. [/eyesonly]
    This will show the content to all administrators and to the specific users 'joebob' and 'billyjean,' whether they're administrators or not.

  • [eyesonly logged="in"] Content for logged-in users. [/eyesonly][eyesonly logged="out"] Content for logged-out users. [/eyesonly]
    This will show different content in the same location on the page depending on a user's logged-in or out status.

  • [eyesonly level="administrator"] Content. [/eyesonly]
    This will show the content only to administrators.

  • [eyesonly hide="yes" level="administrator custom_capability"] Content. [/eyesonly]
    This will hide the content only from administrators and from any role that has the 'custom_capability'.

Eyes Only Nesting

  • Eyes Only allows for nested user access shortcodes up to three levels deep. Example:

[eyesonly level="administrator, editor, author"] Restricted content. [eyesonlier level="administrator, editor"] Restricteder content. [eyesonliest level="administrator"] Restrictedest content. [/eyesonliest] More restricteder content. [/eyesonlier] More restricted content. [/eyesonly]

  • It doesn't matter which order you use them in, just so long as you keep your nested levels straight.

Requirements

  • PHP 5.2+

  • WordPress 3.3+

Requires: 3.3 or higher
Compatible up to: 3.9.2
Last Updated: 2014-4-16
Downloads: 7,338

Ratings

5 stars
5 out of 5 stars

Support

2 of 8 support threads in the last two months have been resolved.

Got something to say? Need help?

Compatibility

+
=
Not enough data

0 people say it works.
0 people say it's broken.

100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1
100,1,1 100,1,1 100,1,1 100,1,1 100,1,1 100,2,2
100,1,1
0,1,0 100,1,1
100,1,1
100,1,1
0,1,0