Skip to content

Instantly share code, notes, and snippets.

@imath
Created Apr 30, 2014
Embed
What would you like to do?
Use a filter in bp-custom.php to force activity update type in activity loops
<?php
/**
* This will force every part of the site where an activity loop is used
* to display activity_update type only
*
* Requires BuddyPress 2.0 as bp_is_activity_directory() was introduced in this version
*
* To create the bp-custom.php file, please see:
* http://codex.buddypress.org/plugindev/bp-custom-php/
*
* If you use such a filter, i advise you to "css-hide" the different
* dropdowns (ex: #activity-filter-select {display:none}) to filter
* the activity stream by type as only one will be used.
*/
function xyhavoc_force_activity_updates( $querystring = '', $object = '' ) {
// Bail if the querystring does not concern activities
if ( 'activity' != $object )
return $querystring;
/* Uncoment if you only need this in user's profile pages
if ( ! bp_is_user() )
return $querystring;*/
/* Uncoment if you only need this in single group's pages
if ( ! bp_is_group() )
return $querystring;*/
/* Uncoment if you need only this in activities directory
if ( ! bp_is_activity_directory() )
return $querystring;*/
$querystring = wp_parse_args( $querystring, array( 'action' => '', 'type' => '' ) );
if ( 'activity_update' != $querystring['action'] || 'activity_update' != $querystring['type'] ) {
$querystring['action'] = 'activity_update';
$querystring['type'] = 'activity_update';
}
return $querystring;
}
add_filter( 'bp_ajax_querystring', 'xyhavoc_force_activity_updates', 20, 2 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment