bp_activity_comments_user_avatars

Echo a list of linked avatars of users who have commented on the current activity item.

Description

bp_activity_comments_user_avatars( (array) $args = array() ); 

Use this function to easily output activity comment authors' avatars.

Avatars are wrapped in

  • elements, but you've got to provide your own
      or
        wrapper markup.

  • Parameters (1)

    0. $args — Optional. (array) => array()
    The args.

    Usage

    1. if ( !function_exists( 'bp_activity_comments_user_avatars' ) ) { 
    2. require_once ABSPATH . PLUGINDIR . 'buddypress/bp-activity/bp-activity-template.php'; 
    3.  
    4. // The args. 
    5. $args = array(); 
    6.  
    7. // NOTICE! Understand what this does before running. 
    8. $result = bp_activity_comments_user_avatars($args); 
    9.  

    Defined (1)

    The function is defined in the following location(s).

    /bp-activity/bp-activity-template.php  
    1. function bp_activity_comments_user_avatars( $args = array() ) { 
    2.  
    3. $r = bp_parse_args( $args, array( 
    4. 'height' => false,  
    5. 'html' => true,  
    6. 'type' => 'thumb',  
    7. 'width' => false,  
    8. ) ); 
    9.  
    10. // Get the user IDs of everyone who has left a comment to the current activity item. 
    11. $output = array(); 
    12. $retval = ''; 
    13.  
    14. if ( ! empty( $user_ids ) ) { 
    15. foreach ( (array) $user_ids as $user_id ) { 
    16.  
    17. // Skip an empty user ID. 
    18. if ( empty( $user_id ) ) { 
    19. continue; 
    20.  
    21. // Get profile link for this user. 
    22. $profile_link = bp_core_get_user_domain( $user_id ); 
    23.  
    24. // Get avatar for this user. 
    25. $image_html = bp_core_fetch_avatar( array( 
    26. 'item_id' => $user_id,  
    27. 'height' => $r['height'],  
    28. 'html' => $r['html'],  
    29. 'type' => $r['type'],  
    30. 'width' => $r['width'] 
    31. ) ); 
    32.  
    33. // If user has link & avatar, add them to the output array. 
    34. if ( ! empty( $profile_link ) && ! empty( $image_html ) ) { 
    35. $output[] = sprintf( '<a href="%1$s">%2$s</a>', esc_url( $profile_link ), $image_html ); 
    36.  
    37. // If output array is not empty, wrap everything in some list items. 
    38. if ( ! empty( $output ) ) { 
    39. $retval = '<li>' . implode( '</li><li>', $output ) . '</li>'; 
    40.  
    41. /** 
    42. * Filters the list of linked avatars for users who have commented on the current activity item. 
    43. * @since 1.7.0 
    44. * @param string $retval HTML markup for the list of avatars. 
    45. * @param array $r Array of arguments used for each avatar. 
    46. * @param array $output Array of each avatar found, before imploded into single string. 
    47. */ 
    48. echo apply_filters( 'bp_activity_comments_user_avatars', $retval, $r, $output );