Don't remove the queue just mark it processed.
authorSteve Sutton <steve@gaslightmedia.com>
Fri, 19 Jan 2018 21:56:57 +0000 (16:56 -0500)
committerSteve Sutton <steve@gaslightmedia.com>
Fri, 19 Jan 2018 21:56:57 +0000 (16:56 -0500)
Will have to make more changes now.

classes/notifications.php
models/admin/ajax/runQueue.php

index fc821d0..b58b5c8 100644 (file)
@@ -405,6 +405,27 @@ class GlmNotifications
         );
     }
 
+    /**
+     * markQueueProcessed
+     *
+     * Mark queue row as processed with the current datetime.
+     *
+     * @param mixed $queue_id Id for the queue.
+     *
+     * @access public
+     * @return void
+     */
+    public function markQueueProcessed( $queue_id )
+    {
+        $this->wpdb->update(
+            GLM_MEMBERS_BILLING_PLUGIN_DB_PREFIX . 'notification_queue',
+            array( 'processed_time' => date( 'Y-m-d' ) ),
+            array( 'id' => $queue_id ),
+            array( '%s' ),
+            array( '%d' )
+        );
+    }
+
     /**
      * deleteQueue
      *
index d6c2a5c..28e674e 100644 (file)
@@ -77,7 +77,7 @@ class GlmMembersAdmin_ajax_runQueue
         if ( isset( $queued ) && !empty( $queued ) ) {
             foreach ( $queued as $queue ) {
                 $Notifications->sendEmailNotification( $queue['notification_type'], $queue['account'] );
-                $Notifications->deleteQueue( $queue['id'] );
+                $Notifications->markQueueProcessed( $queue['id'] );
             }
         }
         wp_die();