This isn’t the kind of thing I’m looking for. What I want is just a simple way of calling a scope in the context of a function – it’s the basic stuff like this that every plug-in developer knows, but which is difficult for normal users to figure out. For example, I’ve figured out how to do it with activity types as follows:
in_array( $activity->type, array( 'activity_comment', 'activity_update' ) )
But how do I do it with scopes?
Something like this ?
function bpfr_remove_some_activity_filters( $filters, $context ) {
/**
* Get available filters depending on the scope.
*
* @since 2.1.0
*
* @param string $context The current context. 'activity', 'member',
* 'member_groups', 'group'.
*
* @return string HTML for <option> values.
*/
if ( 'member' == $context ) {
$remove_these = array( 'Updates', 'Posts', 'Comments' ); // case sensitive
foreach ( $filters as $key => $val ) {
if ( in_array( $val, $remove_these ) )
unset( $filters[ $key ] );
}
}
return $filters;
}
add_filter( 'bp_get_activity_show_filters_options', 'bpfr_remove_some_activity_filters', 20, 2 );
Thanks danbp. That’s a potentially very useful piece of code for a site-wide mod in bp-custom.php, but it still isn’t what I’m after. I need to modify a plug-in so that specific functions are restricted to either groups or mentions scopes. So I need a short snippet of code like what I posted above (which restricts the function to activity comments and updates).