WordPress.org

Ready to get started?Download WordPress

Forums

Dependant Links (7 posts)

  1. SomeRandomGuy
    Member
    Posted 6 months ago #

    Hey,

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

    http://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

  2. SomeRandomGuy
    Member
    Posted 6 months ago #

    Does anyone on here have any advice

  3. brockh2446
    Member
    Posted 6 months 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
    Member
    Posted 6 months 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
    Member
    Posted 6 months 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
    Member
    Posted 6 months ago #

    thank you i appreciate that

  7. brockh2446
    Member
    Posted 6 months ago #

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

Reply

You must log in to post.

About this Topic