Got something specific you'd like to learn? Click here to suggest a tutorial!

Learn PHP
WordPress Plugin: Is User Logged In Shortcodes

WordPress Plugin: Is User Logged In Shortcodes

This is a simple plugin that creates two shortcodes: [ islogged ][ /islogged ] and [ notlogged ][ /notlogged ] that will display content for logged in or logged out users respectively. The shortcodes can be embedded into posts or pages.

The logic is based off the is_user_logged_in() WordPress function, but simply creates the above shortcodes so they can be embedded into a post or page without creating a page template or requiring a special plugin to be installed.

This is perfect for membership site owners who want certain content or parts of content to be available only to registered members of their site.

Download

You can download the plugin here.

Installation

  1. Click the download link above and save the .zip file to your computer.
  2. Unzip the folder and upload it to your WordPress plugins folder.
  3. Activate it in the Plugins section of WordPress.

That’s it!

Usage

Currently, there are no options to set for the plugin. You simply wrap the content you’d like to show for logged in users only in the [ islogged ] shortcode tags like this:

[ islogged ]Content to show for logged in users only [ /islogged ]

And, wrap the content you’d like to show for logged out users only in the [ notlogged ] shortcode tags like this:

[ notlogged ]Content to show for logged out user only [ /notlogged ]

Each set of content will now display accordingly.

IMPORTANT NOTE

DO NOT COPY the examples above and expect them to work on your site. You’ll notice the examples above contain extra spaces in the shortcode tags. That is so they will display instead of execute on my site, since I’m running this plugin.

In order for the above tags to work, you’ll need to remove the extra spaces I’ve added in. :) +

That’s it. If you have any questions or issues, please visit the forum.

About John Morris

I'm a Developer at WishList products, creators of WishList Member, instructor for the WishList Member Certified Developers program, and creator of numerous WordPress plugins and PHP applications.

Subscribe and Connect

Subscribe to my RSS feed, follow me on Google+, Twitter, or Facebook, or check out my videos on YouTube.