WordPress.org

Ready to get started?Download WordPress

Forums

show page only to users who are NOT logged in (4 posts)

  1. wertt
    Member
    Posted 4 years ago #

    i've been dabbling with a few different user permission plugins for wordpress, but what i really need is something that can make certain pages only visible to users who aren't logged in. anybody have any experience with this?

    essentially what i want to do is build a login page that will disappear when users login (it will be replaced by another page that's already been built). i've done some thorough searching and have found plenty of ways to only show pages to users who are logged in, but nothing that works the other way around.

  2. Edward Caissie
    Theme Review Admin
    Posted 4 years ago #

    Have you looked at trying something along these lines:

    if ( is_user_logged_in() ) {
      // show some page to logged in users
    } else {
      // show log in page
    }

    From the core ../wp-includes/pluggable.php

    is_user_logged_in (line 718)

    Checks if the current visitor is a logged in user.

    * return: True if user is logged in, false if not logged in.
    * since: 2.0.0

    bool is_user_logged_in ()

    Hope that gets you looking in a direction that works.

  3. Michiel
    Member
    Posted 4 years ago #

    Did it work for you? what is your code? Thx!

  4. Michiel
    Member
    Posted 4 years ago #

    I now use the CaPa plugin and works great!!!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.