wp-useronline icon indicating copy to clipboard operation
wp-useronline copied to clipboard

how to add the count to the admin toolbar

Open pixeline opened this issue 2 years ago • 0 comments

Hi! this is just to share how I display the current online user count in the admin toolbar:


function add_users_online_count_to_admin_toolbar($wp_admin_bar) {

	if (function_exists('users_online')){
		$users_online = get_users_online_count();
		$wp_admin_bar->add_node( array(
			'id'		=> 'users_online',
			'title' => ' users online: '.$users_online ,
			'href' => '#',
		) );
	}
}

add_action('admin_bar_menu', 'add_users_online_count_to_admin_toolbar', 999);

Thank you for this nifty plugin!

pixeline avatar Dec 20 '22 09:12 pixeline