Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: not recently active

@danbp

Participant

Hi @bea107,

some explanation on how to do this, beside reading the codex.

The original core function we want to modify:

/**
 * Format last activity string based on time since date given.
 *
 * @uses bp_core_time_since() This function will return an English
 *       representation of the time elapsed.
 *
 * @param int|string $last_activity_date The date of last activity.
 * @param string $string A sprintf()-able statement of the form '% ago'.
 * @return string $last_active A string of the form '3 years ago'.
 */
function bp_core_get_last_activity( $last_activity_date, $string ) {

	if ( empty( $last_activity_date ) )
		$last_active = __( 'Not recently active', 'buddypress' );
	else
		$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );

	return apply_filters( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
}

To alter it, we have to create a little function. Here’s the custom function which removes the message string:

function bea107_core_get_last_activity( $last_activity_date, $string ) {
		if ( empty( $last_activity_date ) )
				// we do nothing
				$last_active = '';
			else
				$last_active = sprintf( $string, bp_core_time_since( $last_activity_date ) );
		}
add_filter( 'bp_core_get_last_activity', 'bea107_core_get_last_activity' );

If you want to remove the whole filter, you use this

function bea107_remove_last_activity_filter() {
    remove_filter( 'bp_core_get_last_activity', $last_active, $last_activity_date, $string );
}
add_filter( 'bp_core_get_last_activity', 'bea107_remove_last_activity_filter' );

Both function can be added to your child-theme’s functions.php or bp-custom.php

Skip to toolbar