get notification_id in bp_notifications_get_notifications_for_user to delete it
-
hey guys,
when the user have read/clicked on a notification then the notifitcation should automatically delete. i want to do that with a ajax call.so my idea is to add a filter on the function bp_notifications_get_notifications_for_user() to manipulate the output.
but i need for the ajax call a notification_id. so that he knows which notofiation he has to delete.add_filter( 'bp_notifications_get_notifications_for_user', 'bp_follow_notify_format_notifications', 9, 5 ); function bp_follow_notify_format_notifications( $action, $item_id, $secondary_item_id, $total_items, $format = 'string' ) { if ( 'follow_new_post' === $action ) { if ( (int) $total_items > 1 ) { $title = sprintf( __( '%d new posts have been published', 'bp-follow-notify' ), (int) $total_items ); $link = bp_get_notifications_permalink(); } else { $title = sprintf( __( '%s is kiteboarding.', 'bp-follow-notify' ), bp_core_get_user_displayname( $secondary_item_id ) ); $link = get_permalink( $item_id ); } // WordPress Toolbar if ( 'string' === $format ) { $return = apply_filters('bp_follow_notify_notification', '<div onClick="clickedOnNotification('.$notificationID.')" title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '"</div>', $title, site_url().$link ); // Deprecated BuddyBar } else { $return = apply_filters( 'bp_follow_notify_notification', array( 'text' => $title, 'link' => $link ), $link, (int) $total_items, $title, $title ); } return $return; } return $action; }
here is the important line.
$return = apply_filters('bp_follow_notify_notification', '<div
onClick=”clickedOnNotification(‘.$notificationID.’)”title="' . esc_attr( $title ) . '">' . esc_html( $title ) . '"</div>', $title, site_url().$link );
cheers Pau
- You must be logged in to reply to this topic.