Created
May 25, 2019 06:05
-
-
Save KaineLabs/e2d273b871bffb8528cb3cc45f5851a8 to your computer and use it in GitHub Desktop.
Show Only Friends and Groups Activities
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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
Is ‘groups’ referencing the groups directory? I'm guessing this is not the case, but making sure because my page slug is different.