Skip to:
Content
Pages
Categories
Search
Top
Bottom

How to display the user name?


  • eigodeasobo
    Participant

    @eigodeasobo

    I want to display the user name, is there a better way?

    I am displaying it with the following code.

    <div class="nickname">
    <?php global $user_identity; echo $user_identity; ?>
    </div>
    <div class="unique">
    <?php $user = wp_get_current_user(); echo $user -> user_nicename; ?>
    </div>
    

    However, this code does not work when displaying the follower list with “members-loop.php”.

    Do you have any solutions?

    Thanks.

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

  • shanebp
    Moderator

    @shanebp

    You need to explain exactly where you want to display a user name.
    And whether that user is always the current logged-in user.


    eigodeasobo
    Participant

    @eigodeasobo

    I want to display a user name at friends list.

    So, the Friends list is displayed as a template called “members-loop.php”.

    And logging in this case is irrelevant.


    shanebp
    Moderator

    @shanebp

    In the context of the members-loop, use bp_get_member_user_id() to get the user ID.
    Then use that ID for whatever you need.


    eigodeasobo
    Participant

    @eigodeasobo

    Finally, I managed to do it!
    Thanks!

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