Group Mods

  • Profile picture of @mercime
  • Profile picture of r-a-y
  • Profile picture of Hugo

How to print out an Avatar from a user ID (5 posts)

Started 1 year ago by: jordashtalon

  • So I have the User Id of someone in Buddypress.

    What is the function to print out their Avatar?

    What is the function to link to their profile?

  • Profile picture of Chouf1 Chouf1 said 1 year ago:

    http://codex.buddypress.org/developer-docs/buddypress-template-tags/

  • @chouf1

    I tried every relevant Avatar Function on that page, most of them said, “Undefined Function”.

    And the ones that did actually do something didn’t do what I need.

    Do you know which one will print the avatar with a user id specified as a parameter?

  • I guess the function just doesn’t exist…

  • Profile picture of jamz86 jamz86 said 1 year ago:

    If you’re trying to pull just the avatar from within a loop, this shows how to do that:

    http://wpmu.org/how-to-create-a-gallery-of-members-avatars-in-buddypress/

    If you’re trying to pull up someone’s avatar simply by ID, use bp_core_fetch_avatar() like this:

    <?php
            global $bp;
            $the_avatar = $bp->displayed_user->id; //you'd put in whatever function you're using to get the ID here, assign it to a variable
    	echo bp_core_fetch_avatar( 'item_id='.$the_avatar );
    ?>

    Look up bp_core_fetch_avatar() as there are a lot more options than this. For example, do you want a thumbnail or full sized image? There is a way to specify. Hope that helps!!