Skip to content

Instantly share code, notes, and snippets.

@KaineLabs
Created June 4, 2019 05:41
Show Gist options
  • Save KaineLabs/28c1f813d254ec916d0a3dfdec0ffc12 to your computer and use it in GitHub Desktop.
Save KaineLabs/28c1f813d254ec916d0a3dfdec0ffc12 to your computer and use it in GitHub Desktop.
Mark Specific Users as Online Always
<?php
/**
* Mark Specific Users as Online Always In The User Profile Page.
*/
function yzc_mark_users_as_online( $is_online, $user_id ) {
// List of Always Online Users.
$online_users_ids = array( 1, 2, 3 );
if ( in_array( $user_id, $online_users_ids ) ) {
return true;
}
return $is_online;
}
add_filter( 'yz_is_user_online', 'yzc_mark_users_as_online', 10, 2 );
/**
* Mark as Online in Members Directory.
*/
function yzc_mark_users_as_online_in_members_directory( $classes ) {
global $members_template;
$user_id = $members_template->member->id;
// List of Always Online Users.
$online_users_ids = array( 1, 2, 3 );
if ( in_array( $user_id, $online_users_ids ) ) {
$classes[] = 'is-online';
}
return $classes;
}
add_filter( 'bp_get_member_class', 'yzc_mark_users_as_online_in_members_directory' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment