Support » Fixing WordPress » Show a link only if a user is not logged in

  • 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?

Viewing 2 replies - 1 through 2 (of 2 total)
  • 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
    };
    ?>

    ah thanks, I see where I went wrong now.

    Thanks for the help 🙂

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Show a link only if a user is not logged in’ is closed to new replies.