Skip to:

Opened 10 years ago

Closed 10 years ago

Last modified 10 years ago

#5449 closed defect (bug) (no action required)

bp_has_activities - include & exclude no longer working?

Reported by: shanebp's profile shanebp Owned by:
Milestone: Priority: normal
Severity: normal Version: 1.9.2
Component: Activity Keywords:
Cc: shane@…


In template > activity-loop.php


if ( bp_has_activities( bp_ajax_querystring( 'activity'  )  . '&include=3' ) ):

Or this:

if ( bp_has_activities( 'include=3' ) ):

Results in this:
'Sorry, there was no activity found. Please try a different filter.'

Changing to '&exclude=3' shows all members, including user_id 3, so it is effectively ignored.

Change History (5)

#1 @shanebp
10 years ago

  • Cc shane@… added

#2 @boonebgorges
10 years ago

  • Keywords reporter-feedback added

It's working OK for me.

Keep in mind that the 'include' parameter refers to activity IDs. You can filter by users with the 'user_id' parameter. Your "Sorry, there was no activity found" message suggests that you have no activity item with the id 3 in the database.

Also, keep in mind that your first example won't always be parsed correctly. If bp_ajax_querystring( 'activity' ) is empty, then adding &include=3 to it will result in an invalid querystring.

Have another go using these tips, and let me know what you find. If you're still having problems, please post back with details on how to reproduce.

#3 @shanebp
10 years ago

Keep in mind that the 'include' parameter refers to activity IDs.

Duh, so sorry, I was confusing activity loop with members loop.

You can filter by users with the 'user_id' parameter.

So, the 'user_id' parameter will accept a csv string of ids ? Or an array of ids ?

Last edited 10 years ago by shanebp (previous) (diff)

#4 @boonebgorges
10 years ago

  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

Would it be reasonable to request the expansion of the activity loop scope parameter to allow more than one argument?

It'd be complicated. Each value of $scope is shorthand for a combination of other parameters (eg, 'scope=groups' translates to 'object=groups&primary_id=[listofgroupids]'). Allowing for multiple scopes would mean the ability to join parameter combinations into chunks, separated by booleans. This is a pretty major change in the way we currently build our queries. Not out of the question, but definitely too hard to do now. Feel free to open a separate enhancement ticket for it.

For a short term solution to the thread in question, get a list of friend IDs, add the logged-in user to the list, and then pass to 'user_id':

$include = array_merge( array( bp_loggedin_user_id(), friends_get_friend_user_ids( bp_loggedin_user_id() );

#5 @shanebp
10 years ago

  • Keywords reporter-feedback removed

Yup, that's what I was trying, but passing it to the wrong parameter.

Embarrassing, but thanks for responding. And for closing this ticket.

Note: See TracTickets for help on using tickets.