• Hey,

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

    https://www.prowilderness.ca

    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

    Thanks

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter SomeRandomGuy

    (@somerandomguy)

    Does anyone on here have any advice

    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?

    Thread Starter SomeRandomGuy

    (@somerandomguy)

    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

    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.

    Thread Starter SomeRandomGuy

    (@somerandomguy)

    thank you i appreciate that

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

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Dependant Links’ is closed to new replies.