Tagged: buddypress
I was thinking it would be quite cool to add a little green dot to the corner of a users avatar if they are currently online, would that be possible?
Hello Hans,
Thank you for posting. Please try the following code:
add_filter( 'bp_core_avatar_class', function ( $class, $item_id, $object ) { if ( 'user' != $object ) { return $class; } $last_activity_time = bp_get_user_last_activity( $item_id ); // Maybe add 'is-online' class. if ( ! empty( $last_activity_time ) ) { // Calculate some times. $current_time = bp_core_current_time( true, 'timestamp' ); $last_activity = strtotime( $last_activity_time ); $still_online = strtotime( '+5 minutes', $last_activity ); // Has the user been active recently? if ( $current_time <= $still_online ) { $class .= ' is-online'; } } return $class; }, 10, 3 );
It will add a class to the avatar ‘is-online’ with this class you can apply the CSS rule for online users.
Regards
RaviHi Tosin,
Are you referring to blog post comments?Regards
BrajeshThe comments are part of WordPress not BuddyPress and have a very different markup than that of BuddyPress. That’s why it is not available there.
Regards
Brajesh
Viewing 9 posts - 1 through 9 (of 9 total)
The topic ‘ [Resolved] Green dot to the corner of a users avatar if they are currently online’ is closed to new replies.
This topic is: resolved