Last active
August 13, 2023 16:51
-
-
Save KaineLabs/e52d595eef6df92fed848150b0d43737 to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Allow Specific Roles to Delete All Activity Posts
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 Allow Specific Roles to Delete All Activity Posts | |
**/ | |
add_filter( 'bp_activity_user_can_delete', 'yzc_make_other_roles_able_to_delete_activity', 10 ); | |
function yzc_make_other_roles_able_to_delete_activity( $allow ) { | |
// Get Current User Data. | |
$user = get_userdata( get_current_user_id() ); | |
$can_delete_roles = array( 'administrator', 'editor' ); | |
foreach ( $user->roles as $role ) { | |
if ( in_array( $role, $can_delete_roles ) ) { | |
return true; | |
} | |
} | |
return $allow; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment