WordPress and buddypress programming

HOW TO RESTRICT YOUR ACTIVITY STREAM TO FRIENDS ONLY

Viewing 0 reply threads
  • Author
    Posts
    • #3846
      Michael Mc
      Keymaster
      @mkmcst

      The BuddyPress Activity Stream records all sorts of activities within the site. In order to limit this activity stream to friends activities only, you will need to add the following code within the functions.php file of your theme:

      function friends_activities($args)
      	{
      	if (!bp_is_activity_directory() || !is_user_logged_in())
      		{
      		return $args;
      		}
      	$current_user_id = get_current_user_id();
      	$user_ids = friends_get_friend_user_ids($current_user_id);
      	// include users own too
      	array_push($user_ids, $current_user_id);
      	$args['user_id'] = $user_ids;
      	// print_r($args);
      	return $args;
      	}
      add_filter('bp_after_has_activities_parse_args', 'friends_activities');
Viewing 0 reply threads
  • You must be logged in to reply to this topic.