WooCommerce & WordPress Tutorials Community WordPress How can I tell if a WordPress user is logged in?

Tagged: 

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • DBurk
    Participant
    Post count: 5

    I want to show some content only to logged in users in WordPress, but I don’t know how to check if a WordPress user is logged in.

    webroom
    Keymaster
    Post count: 14

    Try this:

    <?php if ( is_user_logged_in() ) { ?>
        <a href="<?php echo wp_logout_url(); ?>">Logout</a>
    <?php } else { ?>
        <a href="/wp-login.php" title="Members Area Login" rel="home">Members Area</a>
    <?php } ?>

    See: How to check if user is logged-in in WordPress

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.