Skip to content

Instantly share code, notes, and snippets.

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/fcc689e568dc2dab29216087724fe845 to your computer and use it in GitHub Desktop.
Save KaineLabs/fcc689e568dc2dab29216087724fe845 to your computer and use it in GitHub Desktop.
Disable Messages "Compose" Tab By Role.
<?php
/**
* # Disable Messages "Compose" Tab By Role.
*/
function yzc_remove_compose_message_page_by_role() {
// 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 ) ) {
bp_core_remove_subnav_item( 'messages', 'compose' );
}
}
add_action( 'bp_setup_nav', 'yzc_remove_compose_message_page_by_role', 15 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment