Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save KaineLabs/e2d273b871bffb8528cb3cc45f5851a8 to your computer and use it in GitHub Desktop.

Select an option

Save KaineLabs/e2d273b871bffb8528cb3cc45f5851a8 to your computer and use it in GitHub Desktop.
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' );
@Zanyprogressive
Copy link
Copy Markdown

Is ‘groups’ referencing the groups directory? I'm guessing this is not the case, but making sure because my page slug is different.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment