BuddyDev

Search

Green dot to the corner of a users avatar if they are currently online (2)

  • Participant
    Level: Guru
    Posts: 885
    Tosin on #47310

    Hello Ravi,

    Sorry for going back to this topic, please can you help modify your code to be excluded on specific pages like (homepage, invite-friends and ivr) pages

     /* Add green dot to the corner of a users avatar if they are currently online */
    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 ); 

    Thank you sir

  • Keymaster
    Level: Yogi
    (BuddyDev Team)
    Posts: 2889
    Ravi on #47355

    Hello Tosin,

    Try using functions ‘is_home’, ‘is_front_page’, and ‘is_page’ for skipping. Please check.

    Regards
    Ravi

  • Participant
    Level: Initiated
    Posts: 1
    Tania on #51144

    Hello. And in which files should I add the css?

  • Keymaster
    (BuddyDev Team)
    Posts: 24080
    Brajesh Singh on #51149

    Hi,
    Please login to your Dashboard and visit Appearance->Customize-> “Additional Css”
    You can add any custom css there.

    PS:- In future, Please open a new topic and feel free to reference old topics. That will help us serve you better.

    Regards
    Brajesh

You must be logged in to reply to this topic.

This topic is: not resolved