• I needed a simple dashboard widget to let me know if a specific user is online. In order to get login status of that specific user ( this case the user id is 19), I have tried to put a code together after some copy paste. Being a novice I wanted someone experienced to take a look to check if something is wrong, as it does not seem to work. The widget is to be visible to admin only.

    if ( current_user_can('manage_options')) {
    add_action('wp_dashboard_setup', 'add_dashboard_widgets' );
    
    function add_dashboard_widgets() {
    	wp_add_dashboard_widget('dashboard_widget', 'ONLINE STATUS', 'dashboard_widget_function');
    }
    
    function dashboard_widget_function() {
     $current_user = wp_get_current_user();
     if ( 19 == $current_user->ID ) {
        echo 'ONLINE';
     } else {
        echo 'OFFLINE';
    }}
    }


    [Duplicate of https://www.ads-software.com/support/topic/display-online-status-of-users-in-the-wordpress-admin-dashboard?replies=1 ]

  • The topic ‘Dashboard widget to check if specific user is online’ is closed to new replies.