Skip to:
Content
Pages
Categories
Search
Top
Bottom

Reply To: How would I filter the text from the favorite button?

@godavid33

Participant

This ended up being my final code. Sure I could have done it a bit easier but just wanted to cover the base of getting it done first off.


remove_action( 'wp_ajax_activity_mark_fav', 'bp_dtheme_mark_activity_favorite' );
remove_action( 'wp_ajax_nopriv_activity_mark_fav', 'bp_dtheme_mark_activity_favorite' );

remove_action( 'wp_ajax_activity_mark_unfav', 'bp_dtheme_unmark_activity_favorite' );
remove_action( 'wp_ajax_nopriv_activity_mark_unfav', 'bp_dtheme_unmark_activity_favorite' );

function custom_like_text(){
	// Bail if not a POST action
	if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
		return;

	if ( bp_activity_add_user_favorite( $_POST['id'] ) )
		_e( '[custom unlike text]', 'buddypress' );
	else
		_e( '[custom like text]', 'buddypress' );

	exit;
}

function custom_unlike_text(){
	// Bail if not a POST action
	if ( 'POST' !== strtoupper( $_SERVER['REQUEST_METHOD'] ) )
		return;

	if ( bp_activity_remove_user_favorite( $_POST['id'] ) )
		_e( '[custom like text]', 'buddypress' );
	else
		_e( '[custom unlike text]', 'buddypress' );

	exit;
}

add_action( 'wp_ajax_activity_mark_fav', 'custom_like_text' );
add_action( 'wp_ajax_nopriv_activity_mark_fav', 'custom_like_text' );

add_action( 'wp_ajax_activity_mark_unfav', 'custom_unlike_text' );
add_action( 'wp_ajax_nopriv_activity_mark_unfav', 'custom_unlike_text' );
Skip to toolbar