WordPress.org

Ready to get started?Download WordPress

Forums

Show a link only if a user is not logged in (3 posts)

  1. HorrorUK
    Member
    Posted 2 years ago #

    I want to show a 'Register' link only when a user is not logged in.

    I found some code that I've used, but it doesn't show up when a user is not logged in:

    <?php
    if ( is_user_logged_in() ) {
    
    } else {
        <a href="http://writers-site.com/whmcs-2/?ccce=register">Sign Up</a>
    };
    ?>

    I'm using it in the PHP Widget.

    Is this code correct, or should I use something else?

  2. netcs.vg
    Member
    Posted 2 years ago #

    posted code is mixing php and html, try this:

    <?php
    if ( is_user_logged_in() ) {
    
    } else { ?>
        <a href="http://writers-site.com/whmcs-2/?ccce=register">Sign Up</a>
       <?php
    };
    ?>
  3. HorrorUK
    Member
    Posted 2 years ago #

    ah thanks, I see where I went wrong now.

    Thanks for the help :)

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags