Tips and Tricks HQ Support

Support site for Tips and Tricks HQ premium products

  • Home
  • Contact Us
  • Documentation
  • Forum Home
    • Forum
    • Forum Search
    • Forum Login
    • Forum Registration

Question about adding login status to Nav bar on page

by

Tips and Tricks HQ Support Portal › Forums › WP eMember › Question about adding login status to Nav bar on page

Tagged: login, navbar

  • This topic has 9 replies, 4 voices, and was last updated 12 years, 4 months ago by amin007.
Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • January 13, 2010 at 1:30 am #652
    rjd2
    Member

    I would like to have an area on a nav bar that indicates that the user is “Logged In” or “Logged Out”. If they are logged out I would like to have something shown like “Login | Register” and have it redirect them to the “registration” page if they need a new account. If they already have an account I would like it to show “User Logged In” in the same area on the nav bar.

    How would I do something like this?

    January 13, 2010 at 7:50 am #17190
    amin007
    Participant

    You will need to add a bit of PHP code to check if the member is logged in or not and depending on that you can show different links.

    Following is an example of PHP code that you can potentially use

    if (function_exists('wp_eMember_install'))
    {
    $emember_auth = Emember_Auth::getInstance();
    $user_id = $emember_auth ->getUserInfo('member_id');
    if (!empty($user_id))
    {
    //Member is logged in so display whatever you want
    }
    else
    {
    //Member is not logged in
    }
    }

    January 13, 2010 at 6:57 pm #17191
    rjd2
    Member

    Please bear with me here since I am still pretty new at PHP.

    In wordpress i have my header.php file and I would like to add this code in there somewhere to show something like “Login | Register” or if they are already logged in, “Logged in as USERNAME | Edit Profile | Logout”.

    The code would be similar to this (with hyperlinks of course). Do I need to make sure my header.php file knows where the wp_eMember_install() function is located? ie, which file it is located in within the eMember plugin files?

    if (function_exists(‘wp_eMember_install’))

    {

    global $auth;

    $user_id = $auth->getUserInfo(‘member_id’);

    if (!empty($user_id))

    {

    // Display “Logged in as USERNAME | Edit Profile | Logout”

    }

    else

    {

    //Display “Login | Register”

    }

    }

    January 14, 2010 at 12:00 am #17192
    amin007
    Participant

    You should just be able to place the above code in your “header.php”. WordPress knows if that function is available or not

    January 14, 2010 at 7:24 pm #17193
    hermedia
    Member

    Tried this :) inserted into header.php (where my WP login plugin was inserted) and it’s not showing


    <?php

    if (function_exists(‘wp_eMember_install’))

    {

    global $auth;

    $user_id = $auth->getUserInfo(‘member_id’);

    if (!empty($user_id))

    {

    //Member is logged in so display whatever you want

    }

    else

    {

    //Member is not logged in

    }

    } ?>


    January 14, 2010 at 11:11 pm #17194
    amin007
    Participant

    Did you just paste the exact same thing or did you actually put the code where it has the comment like:

    //Member is logged in so display whatever you want

    You will need to add in your HTML code that you want in the block where it’s a comment telling you that you need place your HTML code there.

    November 15, 2010 at 5:12 pm #17195
    gcollignon
    Member

    Hi, I am trying this too, but I don’t know what to put instead of //Member is logged in so display what you want.

    Thanks :)

    November 16, 2010 at 1:28 am #17196
    amin007
    Participant

    You put whatever message you want to display to your members.

    November 17, 2010 at 2:11 am #17197
    gcollignon
    Member

    Hi Amin, thanks for your response. I am still a little bit confused.

    How do I display the information like you mentioned above:

    -Display “Logged in as USERNAME | Edit Profile | Logout”

    Thanks

    Gabriel

    November 17, 2010 at 5:28 am #17198
    amin007
    Participant

    You will have to code it up but if you don’t have PHP coding knowledge then try to use this compact login option explained here:

    http://www.tipsandtricks-hq.com/wordpress-membership/using-a-compact-login-and-join-us-message-203

  • Author
    Posts
Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.
Log In

Forum Related

  • Forum Home
  • Forum Search
  • Forum Login

Support Related Forms

  • Contact Us
  • Customer Support
  • Request a Plugin Update
  • Request Fresh Download Links

Useful Links

  • Plugin Upgrade Instructions
  • WP eStore Documentation
  • WP eMember Documentation
  • WP Affiliate Platform Documentation
  • WP PDF Stamper Documentation
  • WP Photo Seller Documentation
  • Tips and Tricks HQ Home Page
  • Our Projects

Quick Setup Video Tutorials

  • WP eStore Video Tutorial
  • WP eMember Video Tutorial
  • WP Affiliate Platform Video Tutorial
  • Lightbox Ultimate Video Tutorial
  • WP Photo Seller Video Tutorial

Our Other Plugins

  • WP Express Checkout
  • Stripe Payments Plugin
  • Simple Shopping Cart Plugin
  • Simple Download Monitor

Copyright © 2023 | Tips and Tricks HQ