To change your site users’ status in accordance with CometChat’s status, use cometchat_status table and lastactivity field from your users table.
The following code is used to set users status:
if (((time()-$lastactivity) < ONLINE_TIMEOUT) && $status != 'invisible' && $status != 'offline') {
if ($status != 'busy' && $status != 'away') {
$status = 'available';
}
} else {
$status = 'offline';
}
ONLINE_TIMEOUT is a cometchat standard variable which is defined in cometchat/config.php file, which stores default online time out value. This value is by default set to 60
$lastactivity variable should contain the value of the “lastactivity” field from your users table for that user (in UNIX TIMESTAMP format)
$status variable should contain the value of the “status” field from the table cometchat_status for the user.
Not finding what you need?
The CometChat team is here to help!