WordPress.org

Ready to get started?Download WordPress

Forums

Login link only for new users? (3 posts)

  1. venug
    Member
    Posted 3 years ago #

    Hi !
    I am trying to use this function in theme header to implement redirection for users while registering/logging

    <a href="<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>

    At the same time I want to hide the link after logging in. Currently the link is appearing even for logged in users

    So I have used :

    <?php
    if ( is_user_logged_in() ) {
        echo 'Welcome, registered user!';
    } else {
        echo 'Welcome, visitor!';
    }
    ?>

    But the link is broken when I used it. Could anybody help me?

    Thanks !

  2. venug
    Member
    Posted 3 years ago #

    This is the code I used in theme header.php file combining the both codes for redirection and user based Access. But it is broken

    <?php
    if ( is_user_logged_in() ) {
    echo 'Welcome, registered user!';
    } else {
    echo '" title="Login">Login';
    }
    ?>

    Does any one have Idea about this?

  3. venug
    Member
    Posted 3 years ago #

    Sorry ! There was a mistake in my last message. This is the actual code I tried, but failed :

    <?php
    if ( is_user_logged_in() ) {
    echo 'Welcome, registered user!';
    } else {
    echo '<a href =  "<?php echo wp_login_url( get_permalink() ); ?>" title="Login">Login</a>';
    }
    ?>

Topic Closed

This topic has been closed to new replies.

About this Topic