Last active
August 4, 2023 13:14
-
-
Save wbcomdev/f35186c63a9f4d3eae4477de63616eda to your computer and use it in GitHub Desktop.
code snippet for remove specific user role from the suggestion widget
This file contains hidden or 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 | |
| /** | |
| * Wbcom Designs - Remove specific user role form suggestion list | |
| * | |
| * @param array $matched_members get users id. | |
| */ | |
| function bffs_remove_admin_role( $matched_members ) { | |
| foreach ( $matched_members as $matched_member ) { | |
| $user_data = get_userdata( $matched_member ); | |
| $restrict_role = array(); | |
| if ( 'administrator' === $user_data->roles[0] ) { | |
| $restrict_role[] = $user_data->data->ID; | |
| } | |
| $matched_members = array_diff( $matched_members, $restrict_role ); | |
| } | |
| return $matched_members; | |
| } | |
| add_filter( 'bffs_remove_specific_role_from_suggestion_widget', 'bffs_remove_admin_role', 10, 1 ); | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment