/**
 * Removes notifications made by a user.
 *
 * @since 1.2.1
 *
 * @param int $user_id The user ID.
 */
function bp_follow_remove_notifications_for_user($user_id = 0)
{
    // BP 1.9+
    if (bp_is_active('notifications')) {
        bp_notifications_delete_all_notifications_by_type($user_id, buddypress()->follow->id, 'new_follow');
        // BP < 1.9 - delete notifications the old way
    } elseif (!class_exists('BP_Core_Login_Widget')) {
        global $bp;
        bp_core_delete_notifications_from_user($user_id, $bp->follow->id, 'new_follow');
    }
}
/**
 * Delete at-mention notifications when the corresponding activity item is deleted.
 *
 * @since 2.0.0
 *
 * @param array $activity_ids_deleted IDs of deleted activity items.
 */
function bp_activity_at_mention_delete_notification($activity_ids_deleted = array())
{
    // Let's delete all without checking if content contains any mentions
    // to avoid a query to get the activity.
    if (bp_is_active('notifications') && !empty($activity_ids_deleted)) {
        foreach ($activity_ids_deleted as $activity_id) {
            bp_notifications_delete_all_notifications_by_type($activity_id, buddypress()->activity->id);
        }
    }
}
/**
 * Remove all notifications for any member belonging to a specific group.
 *
 * @since 1.9.0
 *
 * @param int $group_id ID of the group.
 */
function bp_groups_delete_group_delete_all_notifications($group_id)
{
    if (bp_is_active('notifications')) {
        bp_notifications_delete_all_notifications_by_type($group_id, buddypress()->groups->id);
    }
}
/**
 * Delete notifications if the idea was removed
 *
 * @package WP Idea Stream
 * @subpackage buddypress/notifications
 *
 * @since  2.0.0
 *
 * @param  int $idea_id the ID of the idea
 * @uses   wp_idea_stream_get_post_type() to get the ideas post type identifier
 * @uses   get_post_type() to get the post type of the trashed post
 * @uses   bp_notifications_delete_all_notifications_by_type() to delete the notification
 * @uses   buddypress() to get BuddyPress instance
 */
function wp_idea_stream_buddypress_delete_notifications_by_post_id($idea_id = 0)
{
    // Bail if not the idea post type.
    if (wp_idea_stream_get_post_type() != get_post_type($idea_id)) {
        return;
    }
    bp_notifications_delete_all_notifications_by_type($idea_id, buddypress()->ideastream->id);
}
/**
 * Delete all notifications for by type
 *
 * @deprecated Deprecated since BuddyPress 1.9.0. Use
 *  bp_notifications_delete_all_notifications_by_type() instead.
 *
 * @since BuddyPress (1.0)
 * @param int $user_id
 * @param string $component_name
 * @param string $component_action
 * @return boolean True on success, false on fail
 */
function bp_core_delete_all_notifications_by_type($item_id, $component_name, $component_action = false, $secondary_item_id = false)
{
    // Bail if notifications is not active
    if (!bp_is_active('notifications')) {
        return false;
    }
    // Trigger the deprecated function notice
    _deprecated_function(__FUNCTION__, '1.9', 'bp_notifications_delete_all_notifications_by_type()');
    bp_notifications_delete_all_notifications_by_type($item_id, $component_name, $component_action, $secondary_item_id);
}
Esempio n. 6
0
 /**
  * Remove answer notification when corresponding answer get deleted
  * @param  object $comment
  * @return void
  */
 public function remove_comment_notify($comment)
 {
     if (bp_is_active('notifications')) {
         bp_notifications_delete_all_notifications_by_type($comment->comment_post_ID, buddypress()->ap_notifier->id, 'new_comment_' . $comment->comment_post_ID);
     }
 }
 /**
  * On Comment Delete
  * @param type $comment_id
  */
 public function comment_deleted($comment_id)
 {
     if (!$this->is_bp_active()) {
         return;
     }
     bp_notifications_delete_all_notifications_by_type($comment_id, $this->id);
     $this->unmark_notified($comment_id);
 }