Skip to:
Content
Pages
Categories
Search
Top
Bottom

Show logged in firstname outside the loop


  • Mat
    Participant

    @mat2010

    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)

  • Mat
    Participant

    @mat2010

    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.


    Mat
    Participant

    @mat2010

    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 ! 🙂


    Mat
    Participant

    @mat2010

    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