Created
July 12, 2017 20:26
-
-
Save JarrydLong/2336e299ef2b57ce9c25193310f786ce to your computer and use it in GitHub Desktop.
Hide all menu items except for the Live Chat dashboard to agents
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
add_action( 'init', 'wplc_remove_non_agent_menu_items' ); | |
function wplc_remove_non_agent_menu_items(){ | |
if( !current_user_can( 'manage_options' ) ){ | |
remove_action('admin_menu', 'wplc_admin_menu_pro'); | |
remove_action('admin_menu', 'wplc_admin_menu', 4); | |
add_action('admin_menu', 'wplc_new_agent_dashboard' ); | |
} | |
} | |
function wplc_remove_quick_responses_non_agent( $args, $post_type ) { | |
$wplc_current_user = get_current_user_id(); | |
if( ( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) || current_user_can("wplc_ma_agent") ) && !current_user_can( 'manage_options' ) ){ | |
if ( $post_type == "wplc_quick_response" ) { | |
$args['show_in_menu'] = ""; | |
} | |
} | |
return $args; | |
} | |
add_filter( 'register_post_type_args', 'wplc_remove_quick_responses_non_agent', 20, 2 ); | |
function wplc_new_agent_dashboard(){ | |
$wplc_current_user = get_current_user_id(); | |
if( get_user_meta( $wplc_current_user, 'wplc_ma_agent', true ) || current_user_can("wplc_ma_agent")){ | |
add_menu_page('WP Live Chat', __('Live Chat', 'wplivechat'), 'wplc_ma_agent', 'wplivechat-menu', 'wplc_admin_menu_layout', 'dashicons-format-chat'); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment