Created
August 31, 2018 03:08
-
-
Save KaineLabs/fcc689e568dc2dab29216087724fe845 to your computer and use it in GitHub Desktop.
Disable Messages "Compose" Tab By Role.
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 | |
/** | |
* # 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