Last active
August 16, 2021 00:34
-
-
Save KaineLabs/700981584625c5e2a2340cb821e7ae8c to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Hide Reviews by 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 | |
/** | |
* Youzify - BuddyPress Hide Reviews by Role. | |
*/ | |
add_filter( 'youzify_is_user_can_receive_reviews', 'yzc_hide_reviews_for_specific_roles', 10, 2 ); | |
function yzc_hide_reviews_for_specific_roles( $default, $user_id ) { | |
if ( empty( $user_id ) ) { | |
return $default; | |
} | |
// Get User Data. | |
$user = get_userdata( $user_id ); | |
// Which roles can't have reviews. | |
$forbidden_roles = array( 'subscriber', 'participant' ); | |
foreach ( $user->roles as $role ) { | |
if ( in_array( $role, $forbidden_roles ) ) { | |
return false; | |
} | |
} | |
return $default; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment