[buddypress-trac] [BuddyPress Trac] #4988: bp_has_activities to accept multi scope
buddypress-trac
noreply at wordpress.org
Thu Aug 28 04:31:57 UTC 2014
#4988: bp_has_activities to accept multi scope
-------------------------+------------------
Reporter: henrywright | Owner:
Type: enhancement | Status: new
Priority: normal | Milestone: 2.2
Component: Activity | Version: 1.2
Severity: normal | Resolution:
Keywords: has-patch |
-------------------------+------------------
Comment (by r-a-y):
> A couple thoughts about how the proposed API syntax looks. Some of this
is in contradiction to my initial thoughts yesterday, so bear with me :)
I kinda like the current syntax as it's easy to write scopes for. We also
have to keep in mind that whatever syntax we decide will be used by plugin
authors.
----
{{{
(
( item_id = 5 )
AND
( component = 'blogs' OR type = 'activity_update' )
)
OR
(
( component = 'groups' )
AND
( item_id = 6 )
)
}}}
This is probably the worse example for endorsing nested relation queries
;) With that being said, here's how to translate that example into a
`BP_Activity_Query` in the latest patch:
{{{
$activity = new BP_Activity_Query( array(
'relation' => 'OR',
// nested relation query
array(
//'relation' => 'AND', // this can be omitted as the
default relation is 'AND'
'item_id' => array( 5 ),
array(
'component' => 'blogs',
'type' => 'activity_update',
'relation' => 'OR',
),
),
// groups
array(
'component' => array( 'groups' ),
'item_id' => array( 6 ),
)
) );
}}}
----
> There's currently no way to do negative filters. If I want to get all
activity from components *other than* 'groups', there should be a way to
do that.
Updated patch supports this. Here's an example:
{{{
$activity = new BP_Activity_Query( array(
array(
'compare' => 'NOT IN',
'component' => 'groups',
)
) );
}}}
----
What are some other `'compare'` types we want to support? I still have to
do some further tweaking, but what do you think about diverging from the
`WP_Meta_Query` syntax?
--
Ticket URL: <https://buddypress.trac.wordpress.org/ticket/4988#comment:6>
BuddyPress Trac <http://buddypress.org/>
BuddyPress Trac
More information about the buddypress-trac
mailing list