Created
September 24, 2020 21:09
-
-
Save KaineLabs/056e6c782f2be268a17f9d8877b23124 to your computer and use it in GitHub Desktop.
Show Following Users Activities + User Own Activities Only
This file contains 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 Following Users Activities + User Own Activities! | |
*/ | |
function yzc_followings_only_activity_args( $args ) { | |
if ( ! bp_is_activity_directory() || ! is_user_logged_in() ) { | |
return $args; | |
} | |
// Get User ID. | |
$user_id = get_current_user_id(); | |
// Get Users. | |
$user_ids = (array) bp_follow_get_following( array( 'user_id' => $user_id ) ); | |
// Include users own too? | |
array_push( $user_ids, $user_id ); | |
$args['user_id'] = $user_ids; | |
return $args; | |
} | |
add_filter( 'bp_after_has_activities_parse_args', 'yzc_followings_only_activity_args' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment