WordPress: Remove Gravatar

A quick tip to remove default wordpress Gravatar avatar links. “avatar.jpg” is default avatar locates at theme directory/images folder, you can change it to any image you want.

// Remove Gravatar
function bp_remove_gravatar ($image, $params, $item_id, $avatar_dir, $css_id, $html_width, $html_height, $avatar_folder_url, $avatar_folder_dir) {

	$default = get_stylesheet_directory_uri() .'/images/avatar.jpg';

	if( $image && strpos( $image, "gravatar.com" ) ){ 

		return '<img class="avatar" src="' . $default . '" alt="avatar" />';
	} else {
		return $image;

	}

}
add_filter('bp_core_fetch_avatar', 'bp_remove_gravatar', 1, 9 );

function remove_gravatar ($avatar, $id_or_email, $size, $default, $alt) {

	$default = get_stylesheet_directory_uri() .'/images/avatar.jpg';
	return "<img class="avatar avatar-{$size} photo avatar-default" src="{$default}" alt="{$alt}" width="{$size}" height="{$size}" />";
}

add_filter('get_avatar', 'remove_gravatar', 1, 5);

function bp_remove_signup_gravatar ($image) {

	$default = get_stylesheet_directory_uri() .'/images/avatar.png';

	if( $image &amp;&amp; strpos( $image, "gravatar.com" ) ){ 

		return '<img class="avatar" src="' . $default . '" alt="avatar" width="60" height="60" />';
	} else {
		return $image;
	}

}
add_filter('bp_get_signup_avatar', 'bp_remove_signup_gravatar', 1, 1 );

Add wordpress custom post-type & comments to Buddypress activity record

By default, Buddypress will not record custom post-type posts and comments. To do that, you can add following functions to your theme function.php file.

// Add custom post type to activity record
add_filter ( 'bp_blogs_record_post_post_types', 'activity_publish_custom_post_types',1,1 );
// Add custom post type comments to activity record
add_filter ( 'bp_blogs_record_comment_post_types', 'activity_publish_custom_post_types',1,1 );

function activity_publish_custom_post_types( $post_types ) {
// add any custom post-type here
$post_types[] = 'videos';
$post_types[] = 'photos';
$post_types[] = 'cheats';
return $post_types;
}

//Modify activity records for custom post-type
add_filter('bp_blogs_activity_new_post_action', 'record_cpt_activity_action', 1, 3);
function record_cpt_activity_action( $activity_action,  $post, $post_permalink ) {
global $bp;
if( $post->post_type != 'post' ) {
	if ( is_multisite() )
	$activity_action  = sprintf( __( '%1$s wrote a new %2$s post, %3$s, on the site %4$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ), $post->post_type, '<a href="' . $post_permalink . '">' . $post->post_title . '</a>', get_blog_option( $blog_id, 'blogname' ));
	else
	$activity_action  = sprintf( __( '%1$s wrote a new %2$s post, %3$s', 'buddypress' ), bp_core_get_userlink( (int) $post->post_author ),$post->post_type, '<a href="' . $post_permalink . '">' . $post->post_title . '</a>' );
} 
return $activity_action;
}

//Modify activity comment records for custom post-type
add_filter('bp_blogs_activity_new_comment_action', 'record_cpt_comment_activity_action', 1, 3);
function record_cpt_comment_activity_action( $activity_action,  &$recorded_comment, $comment_link ) {
global $bp;
if( $recorded_comment->post->post_type != 'post' ) {
		if ( is_multisite() )
			$activity_action = sprintf( __( '%1$s commented on the %2$s post, %3$s, on the site %4$s', 'buddypress' ), bp_core_get_userlink( $user_id ), $recorded_comment->post->post_type, '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>', '<a href="' . get_blog_option( $blog_id, 'home' ) . '">' . get_blog_option( $blog_id, 'blogname' ) . '</a>' );
		else
			$activity_action = sprintf( __( '%1$s commented on the %2$s post, %3$s', 'buddypress' ), bp_core_get_userlink( $user_id ),$recorded_comment->post->post_type, '<a href="' . $post_permalink . '">' . apply_filters( 'the_title', $recorded_comment->post->post_title ) . '</a>' );
} 
return $activity_action;
}

Hope this is useful for your project!