Last active
August 21, 2020 15:09
-
-
Save imanispatel/aa5784a8f2f48d610b66022ae40ae0d1 to your computer and use it in GitHub Desktop.
Hide BUC chat frame for specific users role if select Specific Users option
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 | |
/** | |
* Hide BUC chat frame if select Specific Users option. | |
* | |
* @return void | |
*/ | |
function buc_hide_chat_frame() { | |
if( is_user_logged_in() ) { | |
global $venus_buc; | |
$settings = $venus_buc->get_settings(); | |
$chat_with = isset( $settings['general_general_show_all_users'] ) ? $settings['general_general_show_all_users'] : ''; | |
if ( 'specific_users' == $chat_with ) { | |
$user = wp_get_current_user(); | |
$user_roles = ( array ) $user->roles; | |
$set_roles = isset( $settings['general_general_specific_users'] ) ? $settings['general_general_specific_users'] : ''; | |
if ( is_array( $set_roles ) ) { | |
$result = array_intersect( $user_roles, $set_roles ); | |
if ( empty( $result ) ) { | |
echo '<style>#wp-chat-frame {display: none;}</style>'; | |
} | |
} | |
} | |
} | |
} | |
add_action( 'wp_footer', 'buc_hide_chat_frame' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment