Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/e2d273b871bffb8528cb3cc45f5851a8 to your computer and use it in GitHub Desktop.
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' );
@eltotohgf
Copy link

Y cómo puedo hacer para que en activity stream aparezca la actividad de mi amigos y de los grupos a los que pertenezco (para que me salga la actividad de los grupos incluyendo los miembros de los que no soy amigo). Gracias

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