Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active January 5, 2019 15:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/1f529ac40f77c039416814fa4d50c939 to your computer and use it in GitHub Desktop.
Save KaineLabs/1f529ac40f77c039416814fa4d50c939 to your computer and use it in GitHub Desktop.
Get Wall Activities By User Role
<?php
/**
* Get Wall Activities By User Role.
*/
function yzc_get_activities_by_role( $where ) {
if ( ! bp_is_activity_directory() ) {
return $where;
}
// Get Users with role Hero.
$args = array( 'role' => 'hero', 'fields' => 'ID' );
$users_ids = get_users( $args );
if ( empty( $users_ids ) ) {
return $where;
}
// Add Where Statment.
$where['limit_user'] = 'a.user_id IN(' .implode( ',', $users_ids ) . ')';
return $where;
}
add_filter( 'bp_activity_get_where_conditions', 'yzc_get_activities_by_role' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment