Noptin_New_Post_Notify::notification_complete( $item )

Runs after a post notification has been sent


Source Source

File: includes/class-noptin-new-post-notify.php

	public function notification_complete( $item ) {
		global $wpdb;

		if ( isset( $item['automation_type'] ) && 'post_notifications' === $item['automation_type'] && isset( $item['key'] ) ) {
			$wpdb->delete(
				get_noptin_subscribers_meta_table_name(),
				array( 'meta_key' => '_campaign_' . $item['key'] ),
				'%s'
			);
		}

		if ( ! is_array( $item ) || empty( $item['campaign_id'] ) || empty( $item['associated_post'] ) ) {
			return;
		}

		$post_ids = get_posts(
			array(
				'fields'      => 'ids',
				'numberposts' => -1,
				'post_type'   => 'noptin-campaign',
				'meta_query'  => array(
					array(
						'key'   => 'campaign_type',
						'value' => 'bg_email',
					),
					array(
						'key'   => 'bg_email_type',
						'value' => 'new_post_notification',
					),
					array(
						'key'   => 'associated_campaign',
						'value' => $item['campaign_id'],
					),
					array(
						'key'   => 'associated_post',
						'value' => $item['associated_post'],
					),
				),
			)
		);

		if ( is_array( $post_ids ) ) {
			foreach ( $post_ids as $post_id ) {
				wp_delete_post( $post_id, true );
			}
		}

	}


Top ↑

User Contributed Notes User Contributed Notes

30 day money back guarantee
Safe & Secure online payment
Custom CSS Slide Example
Custom Animation Example
Default Animation