Skip to:
Content
Pages
Categories
Search
Top
Bottom

Detecting user logged in state in WordPress MU / Buddypress

  • @jordashtalon

    Member

    I’m trying to detect a users logged in state and display their gravatar / username at the top of my theme,

    I tried this so far which works in regular wordpress:

    if($current_user->user_login){

    echo ‘Hi, user_login . ‘”>’ . $current_user->display_name;

    echo ‘‘;

    }

    But it’s not working in WPMU / BuddyPress?

    Loving Buddypress so far, it’s an awesome piece of software.

Viewing 5 replies - 1 through 5 (of 5 total)
  • @djpaul

    Keymaster

    Try using is_user_logged_in() and/or bp_loggedin_user_avatar()

    @jordashtalon

    Member

    Hey Thanks, the is_user_logged_in() detected the logged in state, and the bp_loggedin_user_avatar() displayed the image. Now I need to be able to print out the Username, as well as be able to print out a URL to their Profile page (so I can link the image to their profile.)

    Where is a list of functions I can use in BuddyPress?

    Thanks

    @3sixty

    Participant

    Here’s how I do it:

    Print out the Username:

    echo bp_get_loggedin_user_fullname()

    There is also a related function that avoids the need to ‘echo’ that function. Search your bp files for this function and it’s immediately above or below that one.

    Print out a URL to their Profile page:

    echo bp_core_get_userlink( bp_loggedin_user_id() )

    Although I think that gives you a hyperlinked userlink – if you review that function you should be able to figure out a way to output the raw url, if that’s what you are looking for.

    @jordashtalon

    Member

    Thanks 3sixty, that worked perfect, and I found the code to find a users profile URL here is my full code:

    <div class=”userAvatar”>“><?php bp_loggedin_user_avatar(‘width=50&height=50’) ?></div> Welcome Back, <b>“><?php echo bp_get_loggedin_user_fullname() ?></b>

    Where exactly do I go to find the BP Functions?

    I looked here:

    https://codex.buddypress.org/developer-discussions/buddypress-template-tags/

    but alot of the functions don’t work.

    @3sixty

    Participant

    I’d recommend downloading BP 1.2.3 and doing a local search on the files, especially if you plan on doing any more customization – this will save you a lot of time.

    That said, bp-core-templatetags.php probably has most of the functions related to this…

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Detecting user logged in state in WordPress MU / Buddypress’ is closed to new replies.
Skip to toolbar