This simple plugin allows you to easily display different content to users who are logged in and those who are logged out of your site.
Example Usage:
[loggedin]content[/loggedin]
returns content only to logged in users
[loggedout]content[/loggedout]
returns content only to logged out users




6 Comments
Martha
September 4, 2011Hiya,
I’m hosting on Dreamhost and I’ve added this plugin via the site but I don’t see the button on the website home page. The plugin is activated.
How do I get this plug in visible?
Let me know.
Martha
Jack
September 4, 2011Hi Martha,
There won’t be a button visible. You can enter the shortcode directly into the visual editor. The content you place between the shortcodes will be hidden or displayed depending on whether the user is logged in.
Jack
ravinder
October 13, 2011very useful plugin
enggi
October 13, 2011great plugin
Deadpan110
October 17, 2011Great plugin – simple and short – saved me some time writing my own, but have some fixes for you to consider…
1: Security check to see if someone is accessing this file directly
This is not needed because if someone does try to access the file directly, the function ‘add_shortcode’ will not be found (as everything else is within functions, they will never be outputted to your browser – you are more likely to get a 500 – Server Error).
2: the rest can be written as follows:
// [loggedin]content[/loggedin] returns content only to logged in users
function wpfc_logged_in( $atts, $content = null ) {
if (is_user_logged_in()) return do_shortcode($content);
}
add_shortcode(‘loggedin’, ‘wpfc_logged_in’);
// [loggedout]content[/loggedout] returns content only to logged out users
function wpfc_logged_out( $atts, $content = null ) {
if (!is_user_logged_in()) return do_shortcode($content);
}
add_shortcode(‘loggedout’, ‘wpfc_logged_out’);
(I hope the above displays correctly)
Note the changes to the [loggedout] shortcode as ‘else’ is also not needed.
3: Finally the closing PHP tag ‘?>’ this is also not needed – WordPress is now PHP5 and closing tags were abandoned sometime during PHP4 (i think).
Anyways, as above – great and simple – if you want me to send you my fixed version – please email me!
Another note to users of this plugin, you will find WordPress does plop a in when you least expect it… solution is to do:
[loggedin]content
[/loggedin](space here but on one line) [loggedout]content
[/loggedout]
Cheers!
Deadpan110
October 17, 2011Correcting the above:
‘does plop a in’ is supposed to read:
‘does plop a <br /> in’