Tagged: 

  • This topic has 2 replies, 2 voices, and was last updated 11 years ago by dhd.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #16660
    dhd
    Member

    Hi,

    I created a Catch Box child and I placed a small nav in the header (top right corner):
    login | become a member | contact

    After someone logs in, I would like this nav instead:
    my profile | logout | contact

    For the 1st nav I inserted this code in my child’s header.php, right after do_action( 'catchbox_headercontent' ); ?>

    <div id="header-nav">
    <a title="login" href="http://mywebsite.com/login/">Login</a>  |  <a title="member" href="http://mywebsite.com/?page_id=65">Become a member</a>  |  <a title="Contact" href="mailto:[email protected]">Contact</a>
    </div>

    It works.
    Do I need javascript to replace the 1st nav with the 2nd? What would be the proper code?

    And once a user is connected, how can I add some kind of tab indicating this status?

    Thanks for your help.

    #16692
    Sakin
    Keymaster

    @dhd: You can use the is_user_logged_in condition. See the code as below.

    <?php
    if ( is_user_logged_in() ) {
    	echo '<a href="' . wp_logout_url() . '" title="Logout">Logout</a>';  
    } else {
    	echo '<a title="member" href="http://mywebsite.com/?page_id=65">Become a member</a>';
    }
    ?>
    #16710
    dhd
    Member

    Many thanks Sakin. It works perfectly. You saved my life again!

Viewing 3 posts - 1 through 3 (of 3 total)
  • The topic ‘How to change header nav after login?’ is closed to new replies.