Dependant Links (7 posts)

  1. SomeRandomGuy
    Posted 1 year ago #


    Im curious how I'd go about having a link that is dependent on being logged in.


    I'd like to change the "My Account" link on my Navigation Bar to a "Log In" button that would direct you to the login page and once logged in revert back to the "My Account" link

    Ive found this code

    function loginlogout_button() {
    if ( is_user_logged_in() ) {?>
        <div id="loginbutton"><a>" title="Logout">Logout</a></div><?php;
    } else {?>
        <div id="loginbutton"><a href="[USER DEFINED URL]" title="Login">Login</a></div><?php;

    But I'm unsure how to implement it on to my site specifically


  2. SomeRandomGuy
    Posted 1 year ago #

    Does anyone on here have any advice

  3. brockh2446
    Posted 1 year ago #

    You'll need to change the my account menu item to Log In first, and then make the "Log In" button respond to this function upon clicking it. Most likely this function will need to hide inside of your theme's Function.php.

    When users create their account, are they creating a wordpress account or some other account for your site?

  4. SomeRandomGuy
    Posted 1 year ago #

    Yeah they're making a wordpress account to post comments, reviews and make purchases. I havent had much experience with php, was hoping it was something simple haha

  5. brockh2446
    Posted 1 year ago #

    Bah, ignore what I first said, I read your initial post wrong, sorry about that. That function you provided does seem to point us in the right direction. I'll need some time to look at this a little further, but hopefully someone else might chime in before I get back to you.

  6. SomeRandomGuy
    Posted 1 year ago #

    thank you i appreciate that

  7. brockh2446
    Posted 1 year ago #

    I would also maybe post this in the Plugins and Hacks forum they may be able to get you a quicker response.

Topic Closed

This topic has been closed to new replies.

About this Topic