Restrict Content in WordPress to Logged & Non-Logged in User

A need for you to restrict content of a post, page, custom post type or widget in your WordPress powered website may arise.

In this tutorial, I will be showing us how to restrict content to either logged in users or non-logged in users via a set of ProfilePress shortcodes.

To restrict content to registered and logged in users, use the shortcode [pp-logged-users] like so:

To restrict content to non-logged in users, use the shortcode [pp-non-logged-users] like so.

Note: you can use these shortcodes in WordPress posts, pages, custom post types and in widgets (well not without a plugin such as this).

How about if you wish to redirect unregistered or non-logged in users to your website login page when they try to access a post or page, simply insert the shortcode [pp-redirect-non-logged-in-users] to the said post or page. And if you want them redirected to a custom URL, use the shortcode as like so:

To redirect only logged in users to a custom url, use the shortcode pp-redirect-logged-in-users like so:

Remember, if the user isn’t logged in, no redirection will occur.

Conclusion

If you have any pre-purchase question, inquiring or contribution, let us know in the comments or shoot us a mail via support[at]profilepress.net

Subscribe to Receive WordPress Tips, Tutorials & Deals.
Deals, Promotions and coupons are available only to subscribers.

Tags:

8 Comments

  1. Reply

    Janey Lee

    December 13, 2016

    How do i do this on the template level using php?

  2. Reply

    Ankita

    December 17, 2016

    I need a plugin to restrict site for users who are not logged in only from linkedin. Is that possible?

    • Reply

      Agbonghama Collins

      December 17, 2016

      Yes it’s possible using the “pp_before_social_login” action hook.

      Don’t worry, we will provide you a custom code to help you achieve what you seek.

  3. Reply

    Mwiinga

    February 18, 2017

    I need a plugin to restrict users.
    I would the restriction to be done by ROLE.
    A user must be logged in, and must be of a specified ROLE, to be able to access ANY PART of the website.
    Is this possible??
    Thanks..

    • Reply

      Collins Agbonghama

      February 19, 2017

      Hi, we can provide you a custom code snippet to help you achieve the restriction feature you seek that will work alongside ProfilePress.

  4. Reply

    Eva

    April 28, 2017

    Hello. Is it possible to restrict the content so only one user can see the pages asigned to him? I want to make a “intranet” for employees so they can download their paysheet, change the personal data (in case they have to change their bank account, address…), download some files, etc. I want them to have access to only their data and their files… I want to create the pages and select who can view them and who can’t.

    Is it possible with this plugin?

    Thank you.

    • Reply

      Collins Agbonghama

      April 28, 2017

      It’s not possible out of the box but we can help you with a custom code to help you achieve what you seek.


Would you like to share your thoughts?

Your email address will not be published. Required fields are marked *

Join Affiliate Program
  Copyright © 2016, ProfilePress. A product of W3Guy LLC.

Get instant access to all pro add-ons & themes!

Pro add-ons and Pro themes are only available to Developer or Ultimate license-holders. Once you have one of these licenses you’ll have access to all add-ons and themes (including this one), as well as any one we build in the future.

The Ultimate license

Purchase Ultimate license

The Developer license

Get instant access to all official add-ons, themes & more!

Official add-ons and themes are available to all license holders.

Want even more? pro addons or extensions such as email confirmation, MailChimp and WordPress & BuddyPress Profile Sync only are available to Developer and Ultimate license holders. Once you have either ultimate or developer license, you'll have access to all pro themes and add-ons, as well as any we build in the future.

The Ultimate license

Purchase Ultimate license

The Developer license

Purchase Developer license

The Business license

Purchase Business license

The Personal license

Purchase Personal license

Purchase Terms and Refund Policy

Purchase and License Terms

ProfilePress is sold as an automatically recurring subscription that renews each year on the anniversary of the purchase date. It will continue to renew until cancelled.

Automatic renewals are priced at a 30% discount off the price at the time of purchase. The renewal price will never be increased so long as the subscription is not cancelled. If a subscription is cancelled and then re-activated at a later date, and the price of ProfilePress has increased within that period, the renewal price will be priced at a 30% discount off the now-current price.

Refund policy

We firmly believe in and stand behind our product 100%, but we understand that it cannot work perfectly for everyone all of the time. If you are unhappy with your purchase, or you have an issue that we are unable to resolve that makes the system unusable, we are more than happy to provide a complete refund within 30 days of your original purchase.

A few conditions:

  1. We cannot provide refunds due to technical issues unless you allow us to adequately try and assist you. If we are unable to resolve the issue for you, we will provide a refund. Please open contact us before requesting a refund for a technical issue.
  2. Refunds may only be issued within 30 days of the purchase date. After 30 days no refunds can be processed.

To submit a refund request, please open a support ticket.