=== Eyes Only: User Access Shortcode === Name: Eyes Only: User Access Shortcode Contributors: thomstark Author: Thom Stark Donate link: https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=MC429PEHQPWEC Version: 1.5 Requires at least: 3.3 Tested up to: 3.6.1 Stable tag: 1.5 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, BuddyPress, BBPress, BPress, BP, BBP 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. = Mini Update Log = * **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](http://wordpress.org/plugins/eyes-only-user-access-shortcode/changelog/ "Right-Click to Open in New Window") = 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'.* = Requirements = * PHP 5.2+ * WordPress 3.3+ == 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. == Frequently Asked Questions == = Is Eyes Only compatible with BuddyPress and BBPress? = As of version 1.5, yes, for the most part, it is, if you install an additional plugin by a different author. Please read these instructions carefully: *Eyes Only* has been updated for compatibility with the [bbPress2 shortcode whitelist](http://wordpress.org/plugins/bbpress2-shortcode-whitelist/ "Right-Click to Open in New Window") plugin. Here are the steps you should take: * Make sure that your *Eyes Only: User Access Shortcode* is updated to version 1.5 or greater. * Install and activate the [bbPress2 shortcode whitelist](http://wordpress.org/plugins/bbpress2-shortcode-whitelist/ "Right-Click to Open in New Window") plugin by Anton Channing. * Go to Settings > Shortcode whitelist * At the top, you should see a **Detected Plugins** header and then a checkbox next to: *Eyes Only: User Access Shortcode by Thom Stark supports the shortcodes: [eyesonly].* Check that box. * Very important: also type **eyesonly** in the **Manual Additions** textbox. Don't type [eyesonly]. Type it without the brackets. * Now, the shortcode will work in BuddyPress and BBPRess forum posts, topics, comments, etc. * **PLEASE NOTE:** It doesn't work everywhere. For instance, it doesn't seem to work in the forum or group description posts (when a forum is created on the back end). But it DOES work in topics and comments within those forums. In other words, it works on the front-end, but not the back-end, of BP and BBP. At least that's my experience. * Best thing to do is use the code all over the place. See where it works, and see where it doesn't. * Also, it seemed to take a few minutes after first installing the *bbPress2 shortcode whitelist* plugin before the shortcode started working everywhere. After a few page refreshes, it kicked in, and now it works immediately on anything new I create. So don't get exasperated after the first few minutes and give up. Follow those steps and your BP and BBP users will be able to use the [eyesonly] shortcode to their hearts' content. == 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.5 = * Added compatibility with BuddyPress and BBPress forums if used in combination with the [bbPress2 shortcode whitelist](http://wordpress.org/plugins/bbpress2-shortcode-whitelist/ "Right-Click to Open in New Window") plugin by Anton Channing. See the [FAQ](http://wordpress.org/plugins/eyes-only-user-access-shortcode/faq/ "Right-Click to Open in New Window") for instructions. * Optomized the shortcode code to reduce the already negligible server load. No functionality changes. = 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 == Upgrade Notice == = 1.5 = Optimizes shortcode for reduced server load and adds support for BuddyPress and BBPress if used in combination with the *bbPress2 shortcode whitelist* plugin.