Created
May 10, 2021 17:01
-
-
Save imanispatel/ed0b53346897128d6e3560755ebcd7b9 to your computer and use it in GitHub Desktop.
Modify friends list (add some Specific User role User)
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 | |
/** | |
* Add some Specific User role User | |
* | |
* @param array $friend_ids | |
* @param int $user_id | |
* @return array | |
*/ | |
function buc_add_friends_in_list( $friend_ids, $user_id ) { | |
$users_role = array( | |
0 => 'author', | |
1 => 'administrator', | |
); | |
$args = array( | |
'role__in' => $users_role, | |
'fields' => 'ID', | |
'exclude' => array( $user_id ), | |
'orderby' => 'display_name', | |
); | |
$new_friend_ids = get_users( $args ); | |
$friend_ids = array_merge( $friend_ids, $new_friend_ids ); | |
return $friend_ids; | |
} | |
add_filter( 'buc_modify_friends_list', 'buc_add_friends_in_list', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment