Support » Fixing WordPress » About if and echo adds

  • Resolved no_ob

    (@no_ob)


    Hi All,

    As you all know the little line as mentioned below is showing
    the register option wherever you want.
    ” title=”Retrieve password”>Lost your password?

    Now i have made a bar at the top of the page and typed the IF statement as mentioned below.

    If the user is logged in i dont want the wp_lostpassword_url to be shown, so therefor the echo ”;. ELSE if want it to be shown.

    How can i fix this ?

    <?php
    if ( is_user_logged_in() ) {
    echo ”;
    } else {
    echo ”;
    ?>

Viewing 5 replies - 1 through 5 (of 5 total)
  • Here are two ways to display the registration link if the user is not logged in:

    <?php
    if ( is_user_logged_in() ) {
    //do nothing
    } else {
        wp_register();
    };
    ?>

    or another way to write it:

    <?php
    if ( !is_user_logged_in() ){
        wp_register();//display registration link if not logged in
    };
    ?>

    More info on wp_register() here.

    Thread Starter no_ob

    (@no_ob)

    Thx,

    But i was in regards to
    <a href="<?php echo wp_lostpassword_url( $redirect ); ?>" title="Retrieve password">Lost your password?</a>

    I want that link to be dissapeard when a user has been logged on 🙁

    Without the < a href= yadaya it won’t work.

    Thats the whole thing about it. Maybe you know a solution ?

    Cheers

    Hi, try this solution:

    Replace

    <a href="<?php echo wp_lostpassword_url( $redirect ); ?>" title="Retrieve password">Lost your password?</a>

    with

    <?php
    if ( !is_user_logged_in() ) { ?>
    <a href="<?php echo wp_lostpassword_url( $redirect ); ?>" title="Retrieve password">Lost your password?</a>
    <?php }
    ?>

    This way the lost your password link only shows up if they’re not logged in, i.e. will disappear if they’re logged in. Good luck!

    Thread Starter no_ob

    (@no_ob)

    This works great!

    Thx mate!

    Now i have another stupid thing.

    When using login : Wp-LOGIN

    At the pw field i get:
    ? within blocks. You know what i mean ?

    This is instead of the normal balls.

    You know what happend ?

    Thread Starter no_ob

    (@no_ob)

    Issue already solved 😀

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘About if and echo adds’ is closed to new replies.