Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Show Only Friends and Groups Activities
<?php
/**
* Show Only Friends and Groups Activities
*/
function yzc_friends_and_groups_only_activity_args( $args ) {
if( ! bp_is_activity_directory() || ! is_user_logged_in() ) {
return $args;
}
$user_id = get_current_user_id();
$user_ids = friends_get_friend_user_ids( $user_id );
// include users own too?
array_push( $user_ids, $user_id );
$args['user_id'] = $user_ids;
if ( bp_is_active( 'groups' ) ) {
$user_groups = groups_get_user_groups( $user_id );
if ( isset( $user_groups['groups'] ) && ! empty( $user_groups['groups'] ) ) {
$args['object'] = 'groups';
$args['primary_id'] =implode( ',', $user_groups['groups'] ) ;
}
}
return $args;
}
add_filter( 'bp_after_has_activities_parse_args', 'yzc_friends_and_groups_only_activity_args' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment