You can check if the user is tracked as online from anywhere in your code. This tutorial shows example PHP code that you can use in your own plugin or theme.

Here is the basic code that you can use:

<?php

$online = false;
if (function_exists('gdbbx_module_online')) {
  $online = gdbbx_module_online()->is_online($user_id);
}

?>

This code will work even if the plugin’s online module is not active or loaded, so your code will not break if that happens. So, on line 3, $online is defined as false (user is not online). Line 4 checks if the online module is available. If it is, line 5 checks if the user with $user_id value is online. Variable $online will have the value TRUE or FALSE.

You should know that if $user_id is 0 (user is not logged in), the function will always return TRUE. To make sure this works correctly, you should use this code only if the $user_id is not 0.

0
0
20
Rate this article

You are not allowed to rate this post.

Comments

Leave a Reply