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.

This entry was posted in Tech and tagged , . Bookmark the permalink.

20 Responses to BuddyPress hack: remove new member registration from activity stream

  1. Bishwajeet says:

    hey I tred this on my website but no change yet :( hoping for help

  2. rich! says:

    did you add the my_denied_activity_new_member to the theme functions.php file?

  3. Pingback: 7 Useful Hacks and Tutorials From the Buddypress Community This Week - WordPress MU and BuddyPress plugins, themes, support, tips and how to's

  4. rich! says:

    updated to include a quick recount for the pagination

  5. kunal jain says:

    Bishwajeet, I think this only works for BP 1.2. Im looking for a solution for 1.1.3 as well.

  6. Arno Nel says:

    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 ) ”

    ?

  7. rich! says:

    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

  8. Arno Nel says:

    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?

  9. rich! says:

    if the bp-custom.php file no need to activate it – autoloads.

  10. Arno Nel says:

    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:

    –>

  11. rich! says:

    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.

  12. Arno Nel says:

    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?

  13. rich! says:

    I just realized the code above with my blog template is converting into curly single/double quotes – so that is causing the issue.

  14. Arno Nel says:

    would you mind emailing me the functions.php file? would really appreciate it

  15. rich! says:

    I posted a link to a simple plugin version

  16. Pingback: WordPress Arena: A Blog for WordPress Developers, Designers and Bloggers

  17. Pingback: Blog de Desenvolvimento

  18. kunal jain says:

    I tried the plugin but that didnt do anything. Adding the code in bp-custom worked fine. Thanks.

  19. Pingback: New #BuddyPress Block Activity Stream Types plugin | the rich! ramblings

  20. admin says:

    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/

Leave a Reply