Feb 26 2010

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.


Feb 25 2010

BuddyPress hack: disable activity stream comments/favorites for certain types

Want to keep the noise ratio down on activity stream commenting? Besides the built-in

Disable activity stream commenting on blog and forum posts?:

I don’t see a way to implement additional filters on bp_activity_can_comment() nor is there one setup for favorites. (unless i’m not looking hard enough)

So, a quick and dirty function to block out certain activity_types.

add to whatever myhacks/functions php and define the excluded activity types

function my_denied_activity_meta_check($type) {
return in_array($type, array( 'bp_link_vote', 'friendship_created', 'friendship_accepted', 'new_forum_post', 'new_member') );
}

*we are removing the ability for voted up links, friendships, new forum posts for a group and new member registrations.

Then in your favorite theme (i’m using default) under the activity/entry.php file – add the function to the is_user_logged_in() if statement on the comment link and/or favorite link sections:

!my_denied_activity_meta_check( bp_get_activity_type() )

In this case, no comments or favorites when members add a friendship or votes up a link (from the awesome BuddyPress Links plugin)

I submitted trac tickets for BP 1.3 to include filtering on the two items (hopefully not a dup :P )


Feb 20 2010

BuddyPress Sitemap Generator plugin

Download from Wordpress Plugin Repo: BuddyPress Sitemap Generator

Based upon GoogleSitemapGenerator by Arne at www.arnebrachhold.de – BuddyPress Sitemap Generator creates a sitemapindex and child maps for each BuddyPress main component.

Sitemap files:

  • overall activity
  • member listing
  • member listing -> groups slug (onlyif data)
  • member listing -> friends slug (onlyif data)
  • member listing -> profile slug
  • member listing -> activity slugs (main, just-me, friends, groups, favorites, mentions)
  • group listing -> public and private groups (if forums enabled – forum slug)
  • forum topics -> public and private groups only

Does not invoke BP components but rather queries MySQL directly. WP-Cron can be set for valid wordpress intervals and the default is daily.

What to expect:
- no fancy priority
- no options yet besides ping/sitemap location
- limited to 50k urls for each component

Screenshots:


Feb 16 2010

Forcing BuddyPress to utilize user_nicename for member urls and mentions

For an upcoming project that will be utilizing BuddyPress 1.2 – I hit a snag with the user_login and member slugs. Importantly the column user_login may contain an @ symbol or other special characters. Since my user registration is via WordPress the user_nicename column is already cleaned and ready to go.

***WARNING***

This requires editing core files and will break whatever upgrade process you use. Thus I can not guarantee this will work for everyone (I’m already one pint into a Arrogant Bastard Ale) I tried to extract the changes I made, so hopefully this is all of them.

You can download a zip file or see below.

bp-activity-filters.php
104c104,105
< if ( !$user_id = username_exists( $username ) )
---
> //ETIVITI (rich!) force user_nicename
> if ( !$user_id = bp_core_get_userid( $username ) )

bp-core-catchuri.php
115c115,117
< if ( get_userdatabylogin( $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
---
> //ETIVITI (rich!) force user_nicename
> if ( get_user_by('slug', $bp_uri[0] ) || in_array( 'wp-load.php', $bp_uri ) ) {
>

bp-activity.php
114a115,117
> //ETIVITI (rich!) force user_nicename
> $user_nicename = ( !empty( $bp->displayed_user->userdata->user_nicename ) ) ? $bp->displayed_user->userdata->user_nicename : $bp->loggedin_user->userdata->user_nicename;
>
127c130,131
< bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_login ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );
---
> //ETIVITI (rich!) force user_nicename
> bp_core_new_subnav_item( array( 'name' => sprintf( __( '@%s Mentions', 'buddypress' ), $user_nicename ), 'slug' => 'mentions', 'parent_url' => $activity_link, 'parent_slug' => $bp->activity->slug, 'screen_function' => 'bp_activity_screen_mentions', 'position' => 50, 'item_css_id' => 'activity-mentions' ) );

bp-core.php
1001c1001
<
---
> //ETIVITI (rich!) force user_nicename
1003c1003
< return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_login = %s", $username ) ) );
---
> return apply_filters( 'bp_core_get_userid', $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM " . CUSTOM_USER_TABLE . " WHERE user_nicename = %s", $username ) ) );
1040,1043c1040,1041
< if ( defined( 'BP_ENABLE_USERNAME_COMPATIBILITY_MODE' ) )
< $username = $user_login;
< else
< $username = $user_nicename;
---
> //ETIVITI (rich!) force user_nicename
> $username = $user_nicename;

Please let me know if I fudged anything up here…

This will not work with BP_ENABLE_USERNAME_COMPATIBILITY_MODE – not tested with other bp plug-ins.


Feb 16 2010

Mentioned on BuddyPress Major Contributors list

Guess I enjoy finding bugs: http://buddypress.org/about/, thanks! :)


Feb 10 2010

FireNICO v1.2.2 for Firefox 3.6 is up

Sorry, I forgot about the “other” extension :P

Download Now – FireNICO v1.2.2 for Firefox 3.5 to 3.6

See the changelog


Feb 9 2010

Adblock Plus and NICOclub Forums

I recommend installing Adblock Plus and add the following subscription list:

How to add an Adblock Plus Filter Subscription:
Open ADP Options (Tools > Add-Ons > Adblock Plus > Options or right click on ADP status icon > Preferences)
Filters > Add filter subscription
Add a different subscription
Enter a title and this url:

http://update.firenico.com/abp/nico.supersizeme.txt


This will bring FireNICO back up to speed and should improve the the overall experience.