WordPress.org

Ready to get started?Download WordPress

Forums

How to check non registered user and display specified content (3 posts)

  1. artheme
    Member
    Posted 1 year ago #

    Hello, I am new to wordpress and find a problem when trying to display some part of a post/ page to non registered users only and hide it for all registered/ logged in users.

    I get a fatal error message like this:

    Fatal error: Call to undefined function is_user_logged_out() in /home4/username/public_html/xxxxxxxxxxx.com/wp-content/themes/wptheme/functions.php

    My question is what is the opposite of is_user_logged_in() ?

    Thanks

  2. bcworkz
    Member
    Posted 1 year ago #

    You just use the NOT operator '!' to reverse the logic, like so:
    if(!is_user_logged_in()) echo 'You are not logged in!';

  3. artheme
    Member
    Posted 1 year ago #

    Hi...

    Thank you@ It works..

Topic Closed

This topic has been closed to new replies.

About this Topic