Skip to:
Content
Pages
Categories
Search
Top
Bottom

BP 1.7: How do I display username under avatar in activity feed?


  • 3ring
    Participant

    @3ring

    Hey All;

    In the BuddyPress 1.7 activity feed (mytheme/buddypress/activity/entry.php), the user’s avatar gets displayed beside their status update like so:

        <div class="activity-avatar">
          <a href="<?php bp_activity_user_link(); ?>">
            <?php bp_activity_avatar(); ?>
          </a>
        </div>

    I’d like to display the user’s username underneath their avatar, and I tried using this code, but for some reason she no work.

        <div class="activity-avatar">
          <a href="<?php bp_activity_user_link(); ?>">
            <?php bp_activity_avatar(); ?>
          </a>
          <br />
          <a href="<?php bp_activity_user_link(); ?>" class="nicename">
            @<?php bp_get_displayed_user_username(); ?>
          </a>
        </div>

    Would someone please kindly show me how to simply display the user’s username/nicename in the activity feed entry?

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

  • shanebp
    Moderator

    @shanebp

    bp_get_displayed_user_username() will fetch the name but won’t display it.

    So you can do this:

    echo bp_get_displayed_user_username()

    Or use bp_displayed_user_username()


    3ring
    Participant

    @3ring

    Thanks @shanebpdev but neither of those worked?? Have you tried it?


    3ring
    Participant

    @3ring

    @shanebpdev – Should I be declaring a global variable somewhere first?


    shanebp
    Moderator

    @shanebp

    You might need the global
    global $activities_template;

    Try
    echo $activities_template->activity->user_nicename

    or
    echo $activities_template->activity->user_login


    3ring
    Participant

    @3ring

    @shanebpdev – it worked! I used:

            <a href="<?php bp_activity_user_link(); ?>" class="nicename"> 
    			@<?php global $activities_template;
    			echo $activities_template->activity->user_nicename; 
    			?>
            </a>

    Thanks so much for your prompt help!!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘BP 1.7: How do I display username under avatar in activity feed?’ is closed to new replies.
Skip to toolbar