I’m using the Buddypress like plugin which adds the feature to like status updates. Now when a user likes something it doesn’t sent a status notification like other buddypress components do. I tried to edit the plugin’s code to add this functionality and added the following code to bp-like.php, but still didn’t work:
/******************************************************
/* Notification
*****************************************************/
function bp_like_setup_globals() {
global $bp, $current_blog;
$bp->bp_like->id = 'bp_like_notifier';
$bp->bp_like->slug = 'BP_LIKE_SLUG';
$bp->bp_like->notification_callback = 'like_format_notifications';
$bp->active_components[$bp->bp_like->slug] = $bp->bp_like->id;
do_action( 'bp_like_setup_globals' );
}
add_action( 'bp_setup_globals', 'bp_like_setup_globals' );
function like_format_notifications( $action, $item_id, $secondary_item_id, $total_items ) {
global $bp;
$link=like_notifier_activity_get_permalink( $item_id );
if( 'activity_like' == $action ) {
if ( (int)$total_items > 1 )
return apply_filters( 'log_multiple_verifications_notification', '<a href="'. $link .'" title="' . __( 'Likes', 'bp-like' ) . '">' . sprintf( __('You have %d new likes', 'bp-like' ), (int)$total_items ) . '</a>', $total_items );
else
return apply_filters( 'log_single_verification_notification', '<a href="'. $link .'" title="' . __( 'likes', 'bp-like' ) . '">' . sprintf( __('You have %d new like', 'bp-like' ), (int)$total_items ) . '</a>', $total_items );
}
do_action( 'like_format_notifications', $action, $item_id, $secondary_item_id, $total_items );
return false;
}
function like_remove_screen_notifications() {
global $bp;
if($has_access)//if user can view this activity, remove notification(just a safeguard for hidden activity)
bp_core_delete_notifications_for_user_by_type( $bp->loggedin_user->id, $bp->bp_like->id, 'new_like' );
}
add_action( 'bp_activity_screen_single_activity_permalink', 'like_remove_screen_notifications' );
//get the thread permalink for activity
function like_notifier_activity_get_permalink( $item_id, $activity_obj = false ) {
global $bp;
if ( !$activity_obj )
$activity_obj = new BP_Activity_Activity( $item_id );
if ( 'activity_comment' == $activity_obj->type )
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->item_id . '/';
else
$link = $bp->root_domain . '/' . BP_ACTIVITY_SLUG . '/p/' . $activity_obj->id . '/';
return apply_filters( 'like_notifier_activity_get_permalink', $link );
}
and inside bp_like_add_user_like() function I put this after $liked_count = count( $users_who_like ):
bp_core_add_notification( $item_id, $user_id, $bp->bp_like->id, 'activity_like' );
so far this didn’t work.. any idea what I’m missing here?
thanks