Adding a new Activity Stream entry when a user changes his avatar

Here’s a quick tip straight from the BP-Trac created by R-A-Y. Put the snippet below in your child theme’s functions.php or in your bp-custom.php:

/* Add a new activity stream item for when people change their Profile Picute */
function xprofile_new_avatar_activity() {
 global $bp;
 if ( !function_exists( 'bp_activity_add' ) )
 return false;
 $user_id = apply_filters( 'xprofile_new_avatar_user_id', $bp->displayed_user->id );
 $userlink = bp_core_get_userlink( $user_id );
 bp_activity_add( array(
 'user_id' => $user_id,
 'action' => apply_filters( 'xprofile_new_avatar_action', sprintf( __( '%s uploaded a new profile picture', 'buddypress' ), $userlink ), $user_id ),
 'component' => 'profile',
 'type' => 'new_avatar'
 ) );
}
add_action( 'xprofile_avatar_uploaded', 'xprofile_new_avatar_activity' );

Now when a user changes his avatar a new entry gets added to the stream notifying everyone of the new profile picture. Awesome!

Schermafbeelding 2011 03 16 om 7.24.04 PM Adding a new Activity Stream entry when a user changes his avatar

This functionality will probably be added to BP 1.3 so keep an eye out when you update to 1.3 in the future. It might cause a conflict!

Source: R-A-Y his patch on BP-Trac

BuddyPress Hosting Guide Looking for quality BuddyPress hosting? We will guide you through all the available hosting options and help you find the best webhost for your next BuddyPress project!

Something about bowe

BuddyPress fanatic, WordPress Theme designer and MultiSite community builder. Proud co-founder of PressCrew. Loves to use awesome in every sentence. Often described as a Dutch Treehugging Hippie.

5 Responses to Adding a new Activity Stream entry when a user changes his avatar

  1. Jed March 21, 2011 at 4:41 pm #

    Nice theme design on the screenshot… which BP theme is it?

    • Bowe Frankema March 31, 2011 at 7:39 pm #

      It’s a custom theme I’m developing.. it might be released for sale later :-)

  2. Juanma Guerrero June 26, 2012 at 5:41 pm #

    Hi! amazing trick! Will this add the custom filter for selection? or how can I create that, let’s suppose I ‘m recording a custom activity (type => ‘custom_name’ ) can I add a filter somehow for the users to do that or show only that kind of updates in a custom activity loop somewhere? Thanks for all!!!

  3. Juanma Guerrero June 26, 2012 at 8:50 pm #

    Oh, I’ve achieved it :D thanks anyway!


    /**
    * bpfb_activity_links_filter()
    *
    * Adds 'Enlaces' and 'Wall Photos' to activity stream filters.
    *
    */
    function bpfb_activity_links_filter() {
    echo 'Enlaces';
    echo 'Fotos del muro';
    }
    add_action( 'bp_activity_filter_options', 'bpfb_activity_links_filter' );
    add_action( 'bp_member_activity_filter_options', 'bpfb_activity_links_filter' );
    add_action( 'bp_group_activity_filter_options', 'bpfb_activity_links_filter' );

    PS: It’s still a bit hardcoded but anyone can tweak it if needed

  4. Hope January 9, 2013 at 4:39 pm #

    This is nice! Thanks! and how to show the new profile pic with the activity entry so users can comment and like it too ?

Leave a Reply