Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How to count number of favorites for any activity

@danbp

Participant

hi @mahdiar,

of course there is a way ! 😉

Add this to bp-custom.php, and tell us if it is what you needed


function bpfr_fav_count() {
	
	// bail if activity component is not used
	if ( !bp_is_active( 'activity' ) ) {
		return false;
	}

	// action
	$my_fav_count = bp_activity_get_meta( bp_get_activity_id(), 'favorite_count' );

	// formating action result
	if ( ! empty( $my_fav_count ) ) {
		$text = sprintf( _n( 'Favorited by %d user.', 'Favorited by %d users.', $my_fav_count, 'text_domain' ), bp_core_number_format( $my_fav_count ) );	
	}
	
	// output
	echo $text;
}
add_action( 'bp_activity_entry_meta', 'bpfr_fav_count' );
Skip to toolbar