Last active
January 5, 2019 15:19
-
-
Save KaineLabs/1f529ac40f77c039416814fa4d50c939 to your computer and use it in GitHub Desktop.
Get Wall Activities By User Role
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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