Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/e52d595eef6df92fed848150b0d43737 to your computer and use it in GitHub Desktop.
Save KaineLabs/e52d595eef6df92fed848150b0d43737 to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Allow Specific Roles to Delete All Activity Posts
<?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