Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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