BuddyPress hack: remove new member registration from activity stream
Since it was asked (and on the buddypress.org forums). Mute new member activity stream registration (aka, don’t announce your spammers)
add to whatever bp-custom.php or theme functions php and define the filtered bp_has_activities() types
function my_denied_activity_new_member( $a, $activities ) {
//if admin we want to know
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
//new_member is the type name (component is 'profile')
if ( $activity->type =='new_member') {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
}
/* Renumber the array keys to account for missing items */
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action('bp_has_activities','my_denied_activity_new_member', 10, 2 );
Then in your favorite theme (i’m using default) under the activity/index.php file, change up up the select option
<?php if (is_site_admin() ) : ?> <option value="new_member"><?php _e( 'Show New Members', 'buddypress' ) ?></option>--> <?php endif; ?>
I suspect you could take this a little further and check the $activity->date_recorded (ie, display new_member registration after 2 weeks)
UPDATE: I have created a simple BuddyPress Block Activity Stream Types plugin which will block any types being saved to the database.

March 1st, 2010 at 10:47 am
hey I tred this on my website but no change yet
hoping for help
March 1st, 2010 at 4:17 pm
did you add the my_denied_activity_new_member to the theme functions.php file?
March 3rd, 2010 at 11:02 am
[...] Read Full Article » [...]
March 4th, 2010 at 12:57 pm
updated to include a quick recount for the pagination
March 6th, 2010 at 2:01 am
Bishwajeet, I think this only works for BP 1.2. Im looking for a solution for 1.1.3 as well.
March 6th, 2010 at 5:48 am
Hi there
Im a bit of a noob, so need a little more help if possible…
I have a child theme, based on default theme. no real changes in my child theme…
Are you saying i should create a blank functions.php in the child theme and add your Function: “function my_denied_activity_new_member( $a, $activities ) ”
?
March 6th, 2010 at 8:16 am
in that case – i would create a file called bp-custom.php and place it in the /wp-content/plugins/ directory or create your own skeleton plugin
March 6th, 2010 at 8:56 am
Thanks Rich, so… to confirm:
1. Create a blank php file
2. copy/paste the following in:
function my_denied_activity_new_member( $a, $activities ) {
//if admin we want to know
if ( is_site_admin() )
return $activities;
foreach ( $activities->activities as $key => $activity ) {
//new_member is the type name (component is ‘profile’)
if ( $activity->type == ‘new_member’ ) {
unset( $activities->activities[$key] );
$activities->activity_count = $activities->activity_count-1;
$activities->total_activity_count = $activities->total_activity_count-1;
$activities->pag_num = $activities->pag_num -1;
}
/* Renumber the array keys to account for missing items */
$activities_new = array_values( $activities->activities );
$activities->activities = $activities_new;
return $activities;
}
add_action( ‘bp_has_activities’, ‘my_denied_activity_new_member’, 10, 2 );
3. upload to wp-content/plugins
4. activate
right?
March 6th, 2010 at 8:59 am
if the bp-custom.php file no need to activate it – autoloads.
March 6th, 2010 at 9:11 am
great….
so, the same for your other hacks, i can just put them in bp-custom.php
why dont you create the file and share all your hacks in one neat package? just an idea
hehehe
last question, once i have the plugin, i still need to make the change to the child theme right?
ie:
–>
March 6th, 2010 at 9:26 am
Correct – these are just simple hacks that require some theme editing as well. for this one, you want to remove the “Show New Members” drop down filter (noted above)
i have requested a trac ticket on BuddyPress to include some filters/hooks. if this is done, i’ll package everything up into a nice activity management plugin (block types, disable activity-meta functions, etc). i already see the need for managing what info plugins are inserting into the activity stream.
March 6th, 2010 at 4:05 pm
dude. this isnt working for me. everything ive tried doesnt work. i would prefer to do it in functions.php
would you mind creating the file that works and emailing to me?
March 7th, 2010 at 9:17 am
I just realized the code above with my blog template is converting into curly single/double quotes – so that is causing the issue.
March 7th, 2010 at 11:34 am
would you mind emailing me the functions.php file? would really appreciate it
March 8th, 2010 at 9:48 am
I posted a link to a simple plugin version
March 10th, 2010 at 8:33 am
[...] BuddyPressHack: Remove New Member Registration From Activity [...]
March 16th, 2010 at 12:42 pm
[...] Group Wiki Opa! que legal! BuddyPress hack: remove new member registration from activity stream http://blog.etiviti.com/2010/02/buddypress-hack-remove-new-member-registration-from-activity-stream/ ouviram as preces: [...]
March 17th, 2010 at 5:38 am
I tried the plugin but that didnt do anything. Adding the code in bp-custom worked fine. Thanks.
May 27th, 2010 at 6:56 am
[...] This plugin is a simple way to block certain activity stream items from being recorded in the database; this could be new member registrations, joining a group, friendship created and so forth.[...]
May 27th, 2010 at 6:56 am
I have released a new plugin that will block any activity type from being saved to the database.
BuddyPress Block Activity Stream Types
http://blog.etiviti.com/2010/05/buddypress-block-activity-stream-types-plugin/