=== Eyes Only: User Access Shortcode === Name: Eyes Only: User Access Shortcode Contributors: thomstark Author: Thom Stark Version: 1.4 Requires at least: 3.3 Tested up to: 3.6.1 Stable tag: 1.4 License: GPLv3 Tags: User Role, Roles, Custom Roles, Capabilities, Custom Capabilities, User Name, Username, Usernames, User Names, User Login, User Logins, Userlogin, Userlogins, Access, Restricted, Logged In, Logged Out, Shortcode, Shortcodes Show or hide content based on usernames, user roles, capabilities, or logged-in status. == Description == Show or hide content based on usernames, user roles, capabilities, or logged-in status. * **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** * *The shortcode:* [eyesonly][/eyesonly] * *Required attributes:* *either* logged="in|out" *or* level="anyrole, any_capability" *or* username="anyusername" *or all three* * *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 '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'.* == Installation == 1. Upload 'eyes-only-user-access-shortcode/' to the '/wp-content/plugins/' directory. 2. Activate the plugin through the 'Plugins' menu in WordPress. 3. Use the provided shortcode generator/s and use the codes on your pages, posts, widgets, etc. == Screenshots == 1. The Shortcode Generator Meta Box defaults to a closed position so as to be as unobtrusive as possible. 2. You've opened up the Meta Box. (That's so Meta.) Behold! Options. 3. So then you choose some options. 4. Then you make it official. 5. Then you share your secrets. 6. The Option page can be found under Settings > Eyes Only Options == Changelog == = 1.4 = * Major Addition: Now with TinyMCE Shortcode Button and Modal Window for shortcode generation. Like the Meta Box generator, the shortcode Modal can be disabled or its access restricted per user capability. * Option to determine the position of the shortcode button on the TinyMCE panel. * Strengthened Administrator Override feature. It's now essentially fullproof. * The "Configure Options" button in the Meta Box (and Modal window) now only shows up for Administrators. * Tweaked some styles. * Added support and review links to the Options page. = 1.3 = * Major Addition: Now with Options page under the Settings menu. * Added option to hide the shortcode generator (meta box), or, by user capability, to control who sees it. * Added an "Administrator Override" option (activated by default) that prevents users from hiding content from Administrators when activated. * Also fixed a minor issue, the "unexepected characters" warning upon plugin activation. It was harmless, but now it's gone. = 1.2 = * Major Addition: Now with shortcode generator meta box, located beneath the Visual/Text editor on your posts and pages. = 1.1 = * Added the 'username' attribute to allow filtering by specific user logins. = 1.0 = * Initial release Requirements: * PHP 5.2+ * WordPress 3.3+