Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save wbcomdev/7ebd2cfa7a1accac27b504a1e2354776 to your computer and use it in GitHub Desktop.

Select an option

Save wbcomdev/7ebd2cfa7a1accac27b504a1e2354776 to your computer and use it in GitHub Desktop.
<?php
/**
* Sidewide activity stream only for friends.
*
* @param array $args Arguments.
*/
function wbcom_friends_only_activity_args( $args ) {
if ( ! bp_is_activity_directory() || ! is_user_logged_in() || ! empty( $args['scope'] ) ) {
return $args;
}
$user_id = get_current_user_id();
$user_ids = friends_get_friend_user_ids( $user_id );
array_push( $user_ids, $user_id );
$args['user_id'] = $user_ids;
return $args;
}
add_filter( 'bp_after_has_activities_parse_args', 'wbcom_friends_only_activity_args' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment