Skip to content

Instantly share code, notes, and snippets.

@Alimir
Last active March 14, 2022 09:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Alimir/6d5b4322de8bab818cf162bd6a20c8e7 to your computer and use it in GitHub Desktop.
Save Alimir/6d5b4322de8bab818cf162bd6a20c8e7 to your computer and use it in GitHub Desktop.
Display like buttons in buddyboss activites + comments
<?php
// Use this hook to disable default buddyboss like button:
add_filter( 'bp_is_activity_like_active', '__return_false' );
.acomment-wpulike{
border-left: 0;
margin: 15px 0 15px 51px;
padding: 0;
}
<?php
/**
* BuddyBoss activity content display
*
* @return void
*/
function wp_ulike_custom_buddypress_activity_content() {
echo wp_ulike_buddypress('put', array( 'id' => bp_get_activity_id() ));
}
add_action( 'bp_after_activity_activity_content', 'wp_ulike_custom_buddypress_activity_content', 10 );
/**
* Buddyboss activity comments display
*
* @param array $return The list of buttons ordered.
* @param int $activity_comment_id The current activity comment ID.
* @param int $activity_id The current activity ID.
* @return void
*/
function wp_ulike_custom_buddypress_activity_comment_content( &$return, $activity_comment_id, $activity_id ) {
echo sprintf('<div class="acomment-wpulike">%s</div>', wp_ulike_buddypress('put', array( 'id' => $activity_comment_id )));
}
add_action( 'bp_nouveau_return_activity_comment_buttons', 'wp_ulike_custom_buddypress_activity_comment_content', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment