Skip to:
Content
Pages
Categories
Search
Top
Bottom

My Profile Link


  • Tracedef
    Participant

    @tracedef

    I’m trying to create a link that appears in menu bar when user is logged in and is given class of “seleted” when the users is on their profile page… the code below is showing “selected” as the class anytime the user is logged in because I don’t know how to test to see if they are on their admin page… anyone have any ideas?

    <?php if ( is_user_logged_in() ) { ?>

    <li class="selected"><?php bp_loggedinuser_link () ?></li>
    <?php } else { ?>
    <li><?php bp_loggedinuser_link () ?></li>

    <?php } ?>

Viewing 3 replies - 1 through 3 (of 3 total)

  • nicolagreco
    Participant

    @nicolagreco

    it seems good, make a function and add it to the admin bar using add_action

    for exampe:

    function my_own_function() {
    if ( is_user_logged_in() ) { ?>
    <li class="selected"><?php bp_loggedinuser_link () ?></li>
    <?php } else { ?>
    <li><?php bp_loggedinuser_link () ?></li>
    }
    }
    add_action( 'bp_adminbar_menus', 'my_own_function', 6 );

    6 is the position you want on the admin bar.

    I hope i undestand your question


    Tracedef
    Participant

    @tracedef

    Thanks! I don’t know how to make a function, but I did get help from Ron at musupport.net…. this is what we ended up with. I like it because it personalizes the link with the persons name which is a strong call to action for them to look at their own profile and notice a lot of the functionality that otherwise goes unnoticed if you are just looking at the groups, members or blogs pages……:

    <?php if ( is_user_logged_in() ) {
    if ( $displayed_userid == $current_user->ID ) { ?>

    <li class="selected"><?php bp_loggedinuser_link () ?></li>
    <?php } else { ?>
    <li><?php bp_loggedinuser_link () ?></li>

    <?php }

    } ?>


    Tracedef
    Participant

    @tracedef

    Correction:

    <?php if ( is_user_logged_in() ) {
    if ( strpos($_SERVER['REQUEST_URI'], "/members/{$current_user->user_login}/") !== false ) { ?>

    <li class="selected"><?php bp_loggedinuser_link () ?></li>
    <?php } else { ?>
    <li><?php bp_loggedinuser_link () ?></li>

    <?php }
    } ?>

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘My Profile Link’ is closed to new replies.
Skip to toolbar