Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show logged in firstname outside the loop

  • @mat2010

    Participant

    Hello,

    I’m using WP 4.7 and BuddyPress 2.7.3.

    I’m trying to display the username of the current logged in user somewhere in my navigation, outside the BuddyPress loop, before <div id=buddypress></div>.

    More specifically, I want to use bp_get_user_firstname.

    Can you please give me some tips to do so ?

    Thanks !

    Mat

Viewing 3 replies - 1 through 3 (of 3 total)
  • @mat2010

    Participant

    With this :

    $userid = bp_loggedin_user_id();
    echo bp_core_get_user_displayname( $userid ) 

    I can have the full name. Now I try to find the user firstname.

    @mat2010

    Participant

    This seems to work :

    $userid = bp_loggedin_user_id();
    echo bp_get_user_firstname ( bp_get_loggedin_user_fullname ( $userid ) )

    Is it a correct way to do so ?

    Now, what if I want to link this name to the user profile ?

    Any help would be much appreciated ! Thanks ! 🙂

    @mat2010

    Participant

    For the record, this works.

    <?php $userid = bp_loggedin_user_id(); ?>
    <a href="<?php bp_loggedin_user_domain() ?>">Bonjour, <?php bp_get_user_firstname ( bp_get_loggedin_user_fullname ( $userid ) ) ?></a>

    Hope it could help someone. 🙂

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Skip to toolbar