I've searched for plugins but while some do halfway accomplish the task they are normally very complicated.

I'd like to add option to the visibility menu when creating a page (and post, but page is more urgent).

visibility menu wordpress

These options need to be: "Only visible to logged user" and "Only visible to guest (i.e. not logged in"

Does any one know of plugin or and point me in the right direction to write my own?

EDIT: A use case for this is; only show the registration and login pages to 'guests'. A logged-in user doesn't need to see these pages.

2 Answers 2


I've actually done this before with a custom page template rather than with the visibility options ... because both logged in and not logged in users ended up going to the same page. Here's some pseudo-code (i.e. do not actually use the code, but it will give you an idea)

$logged_in = is_user_logged_in();

switch($logged_in) {
    case true:
        // Do stuff for logged in users
    case false:
        // Do stuff for not logged in users

Basically, you check to see if the user is logged in (using a combination of get_currentuserdata() and some checks on their ID). If the user is logged in, you display one block of content. If the user is not logged in, you display another block of content.

I definitely think having a visibility option would be a more elegant solution, but then you'd need two different pages for each kind of user. Would a logged in user see a 404 error page if they went to the wrong site? Or be directed elsewhere? With two separate pages, this is a situation you'll have to handle gracefully.


The Subscribers Only Content plugin will accomplish this.

  • This seems to have the capability of hiding content from 'guests' but not 'from' logged-in users (see question edit for more info). Commented Sep 24, 2010 at 7:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.