BuddyDev

Search

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

  • Participant
    Level: Guru
    Posts: 741
    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: 2502
    Ravi on #47355

    Hello Tosin,

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

    Regards
    Ravi

You must be logged in to reply to this topic.

This topic is: not resolved