Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Last active February 13, 2022 22:28
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KaineLabs/bf9e807ff204a9b93bd3cd08d68b19f5 to your computer and use it in GitHub Desktop.
Save KaineLabs/bf9e807ff204a9b93bd3cd08d68b19f5 to your computer and use it in GitHub Desktop.
Youzify - BuddyPress Disable "Send Message" Button By Role.
<?php
/**
* # Disable "Send Message" Button By Role.
*/
function yzc_disable_send_message_button_by_role( $html ) {
// Get Current User Data.
$user = get_userdata( bp_loggedin_user_id() );
// Get Roles.
$roles = (array) $user->roles;
if ( ! in_array( 'administrator', $roles ) || ! in_array( 'editor', $roles ) ) {
return false;
}
return $html;
}
add_filter( 'youzify_get_send_private_message_button', 'yzc_disable_send_message_button_by_role' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment