How do I select which users have access to the chat session logs in their dashboard?

I am using the Chat 2.1 plugin for Security Officer logs. I need the Supervisors to be able to search the Session Logs without being admin.

  • Sajid

    Hi Denis,
    Hope you are doing good today :slight_smile:

    You can enable chat session logs while adding the chat shortcode. Click on the chat icon in WordPress editor, click on advanced tab and select "Log Creation" enabled as seen in attached screenshot. From here you can add the full chat session logs on same page or display the links to chat logs.

    Hope that helps! feel free to post a reply if you need further assistance :slight_smile:
    Cheers, Sajid

  • Panos

    Hey Denis ,

    I see what you want to achieve here, this feature is only available to admins I'm afraid.

    You can try bu placing the following code in your theme's (child theme's) functions.php file:

    function wpmudev_cl_menu(){
    	global $wpdb, $wpmudev_chat;
    
    	require WP_PLUGIN_DIR . '/wordpress-chat/lib/wpmudev_chat_admin_panels.php';
    	$wpmudev_wchat_admin_panels = new wpmudev_chat_admin_panels();
    
    	add_menu_page( _x( "Chat Session Log", 'page label' ),
    		_x( "Chat Session Log", 'menu label' ),
    		'supervisor',
    		'chat_logs_panel',
    		'wpmudev_chat_logs_page',
    		'dashicons-format-chat'
    	);
    }
    
    function wpmudev_chat_logs_page() {
    			global $wpdb, $wpmudev_chat;
    
    			require_once( WP_PLUGIN_DIR . '/wordpress-chat/lib/wpmudev_chat_admin_session_logs.php' );
    
    			$wpmudev_chat_log_list_table = new WPMUDEVChat_Session_Logs_Table();
    
    			if ( isset( $_GET['message'] ) ) {
    				$message_idx = esc_attr( $_GET['message'] );
    				if ( isset( $wpmudev_chat->_admin_notice_messages[ $message_idx ] ) ) {
    					?>
    					<div id='chat-warning' class='updated fade'>
    					<p><?php echo $wpmudev_chat->_admin_notice_messages[ $message_idx ]; ?></p></div><?php
    				}
    			}
    			if ( ( isset( $_GET['laction'] ) ) && ( $_GET['laction'] == "show" ) ) {
    				?>
    				<div id="wpmudev-chat-messages-listing-panel"
    				     class="wrap wpmudev-chat-wrap wpmudev-chat-wrap-settings-page">
    					<?php //screen_icon('wpmudev-chat'); ?>
    					<h2><?php _ex( "Chat Session", "Page Title", $wpmudev_chat->translation_domain ); ?></h2>
    
    					<p>
    						<a href="admin.php?page=chat_session_logs"><?php _e( 'Return to Logs', $wpmudev_chat->translation_domain ); ?></a>
    					</p>
    					<?php
    					if ( ( isset( $_GET['chat_id'] ) ) && ( ! empty( $_GET['chat_id'] ) ) ) {
    						$chat_id = esc_attr( $_GET['chat_id'] );
    					} else {
    						die();
    					}
    					if ( ( isset( $_GET['session_type'] ) ) && ( ! empty( $_GET['session_type'] ) ) ) {
    						$session_type = esc_attr( $_GET['session_type'] );
    					} else {
    						die();
    					}
    
    					$transient_key = "chat-session-" . $chat_id . '-' . $session_type;
    					if ( defined( 'WP_CACHE' ) && WP_CACHE ) {
    						$chat_session_transient = get_option( $transient_key );
    					} else {
    						$chat_session_transient = get_transient( $transient_key );
    					}
    					if ( ( ! empty( $chat_session_transient ) ) && ( is_array( $chat_session_transient ) ) ) {
    						$chat_session_transient                     = $wpmudev_chat->chat_session_show_via_logs( $chat_session_transient );
    						$chat_session_transient['update_transient'] = 'disabled';
    						$chat_session_transient['box_class']        = '';
    						// Always make sure to keep the chat_id, session_type
    						echo $wpmudev_chat->process_chat_shortcode( $chat_session_transient );
    
    					}
    
    					?>
    				</div>
    				<?php
    
    			} else if ( ( isset( $_GET['laction'] ) ) && ( $_GET['laction'] == "details" ) ) {
    				?>
    				<div id="wpmudev-chat-messages-listing-panel"
    				     class="wrap wpmudev-chat-wrap wpmudev-chat-wrap-settings-page">
    
    					<h2><?php _ex( "Chat Session Messages", "Page Title", $wpmudev_chat->translation_domain ); ?></h2>
    
    					<p>
    						<a href="admin.php?page=chat_session_logs"><?php _e( 'Return to Logs', $wpmudev_chat->translation_domain ); ?></a>
    					</p>
    					<?php
    
    					$wpmudev_chat_log_list_table->prepare_items();
    
    					if ( ( isset( $wpmudev_chat_log_list_table->log_item->deleted ) ) && ( $wpmudev_chat_log_list_table->log_item->deleted == 'yes' ) ) {
    						?>
    						<div id='chat-error' class='error fade'>
    						<p><?php _e( 'This entire Chat Session is marked as hidden. It will not be show on public logs display. You may still hide/unhide or delete individual messages below.', $wpmudev_chat->translation_domain ); ?></p>
    						</div><?php
    					}
    
    					?>
    					<form id="wpmudev-chat-edit-listing" action="" method="get">
    						<input type="hidden" name="page" value="chat_session_logs"/>
    						<?php if ( isset( $_GET['chat_id'] ) ) { ?>
    							<input type="hidden" name="chat_id" value="<?php echo $_GET['chat_id']; ?>"/>
    						<?php } ?>
    						<?php if ( isset( $_GET['lid'] ) ) { ?>
    							<input type="hidden" name="lid" value="<?php echo $_GET['lid']; ?>"/>
    						<?php } ?>
    						<?php if ( isset( $_GET['laction'] ) ) { ?>
    							<input type="hidden" name="laction" value="<?php echo $_GET['laction']; ?>"/>
    						<?php } ?>
    						<?php // The WP_List_table class automatically adds a _wpnonce field with the secret 'bulk-'+ args[plural] as in 'bulk-logs' or 'bulk-messages'. So no need to add another nonce field to the form?>
    
    						<?php $wpmudev_chat_log_list_table->search_box( __( 'Search Messages' ), 'chat-search' ); ?>
    						<?php $wpmudev_chat_log_list_table->display(); ?>
    					</form>
    				</div>
    				<?php
    			} else {
    				?>
    				<div id="wpmudev-chat-messages-listing-panel"
    				     class="wrap wpmudev-chat-wrap wpmudev-chat-wrap-settings-page">
    					<?php //screen_icon('wpmudev-chat'); ?>
    					<h2><?php _ex( "Chat Session Logs", "Page Title", $wpmudev_chat->translation_domain ); ?></h2>
    
    					<p><?php _ex( "", 'page description', $wpmudev_chat->translation_domain ); ?></p>
    					<?php
    
    					$wpmudev_chat_log_list_table->prepare_items();
    					?>
    					<form id="chat-edit-listing" action="?page=chat_session_logs" method="get">
    						<input type="hidden" name="page" value="chat_session_logs"/>
    						<?php $wpmudev_chat_log_list_table->search_box( __( 'Search Logs' ), 'chat-search' ); ?>
    						<?php $wpmudev_chat_log_list_table->display(); ?>
    						<?php // The WP_List_table class automatically adds a _wpnonce field with the secret 'bulk-'+ args[plural] as in 'bulk-logs' or 'bulk-messages'. So no need to add another nonce field to the form?>
    
    					</form>
    				</div>
    				<?php
    			}
    		}
    
    add_action( 'admin_menu', 'wpmudev_cl_menu' );

    Make sure you replace the word "supervisor" (in the first function) with the actual custom role (or role) you want to have access to this menu.

    If this works for you, you will be able to see a new menu item called "Chat Session Log" in your admin menu. If you are having troubles seeing it please try first replacing "supervisor" with the word "manage_options" and log in as admin to check if you see this new menu.

    Please let us know how it goes!

    Kind regards,
    Panos

  • Panos

    Hi Denis ,

    Sorry to hear it didn't work for you.

    I would like to try making it work again if you are OK with it :slight_smile:

    I have attached the same code in a plugin which you can download, install and activate.Normally with this plugin you should see a new admin menu (Chat Session Log) for everyone.

    So, if by installing above plugin you see this menu for every user (admin, editor, subscriber etc) it means that it works and you only need to replace the role in the plugin.

    Please let me know how this goes so we can just replace the role in the next step.

    All of this of course if you still need this functionality :slight_smile:

    Cheers!
    Panos

  • Denis

    Thank you Panos,

    I can see a "Chat Session Log" in the dashboards of the supervisors. It worked when I placed "Edtor" for the role.

    The only problem is that they cannot search and display the logs. We are getting the following error message: "You do not have sufficient permissions to access this page"

    It looks like we are back to them needing admin level and the boss said no.

    Thanks for all your help,

    Denis

  • Panos

    Hey Denis ,

    Sorry it doesn't work for you, it's weird as it works in my installation.

    Would you mind providing ftp access so I can have a better look? You can send that privately through our contact form: https://premium.wpmudev.org/contact/

    Select "I have a different question?" for your topic - this and the subject line ensure that it gets assigned to me.

    Send in:Subject: "Attn: Panos Lyrakis"
    - WordPress admin username
    - WordPress admin password
    - login url
    - FTP credentials (host/username/password)
    - link back to this thread for reference: https://premium.wpmudev.org/forums/topic/how-do-i-select-which-users-have-access-to-the-chat-session-logs-in-their-dashboard
    - any other relevant urls

    Thanks!
    Panos

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.