Created
October 16, 2018 23:54
-
-
Save KaineLabs/15dda79932a0cd9676b38db346c020ae to your computer and use it in GitHub Desktop.
Allow Adding/Editing Reviews for Contributers and Amins Only.
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 | |
/** | |
* Allow Adding/Editing Reviews for Contributers and Amins Only. | |
*/ | |
function yzc_allow_reviews_by_role() { | |
$can = false; | |
// Get Current User Data. | |
$user = wp_get_current_user(); | |
$allowed_roles = array( 'contributor', 'administrator' ); | |
foreach ( $allowed_roles as $role ) { | |
if ( in_array( $role, (array) $user->roles ) ) { | |
$can = true; | |
} | |
} | |
return $can; | |
} | |
add_filter( 'yz_is_user_can_add_reviews', 'yzc_allow_reviews_by_role' ); | |
add_filter( 'yz_is_user_can_edit_reviews', 'yzc_allow_reviews_by_role' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment