adding event confirmation required page with default content
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 15 Jun 2017 20:01:40 +0000 (16:01 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 15 Jun 2017 20:01:40 +0000 (16:01 -0400)
redirecting user to event confirmation page instead of the changing the view to the
confirmation page. adding conditional to check for categories array before trying to
loop through them in the frontAdd model.

models/front/events/frontAdd.php
setup/requiredPages.php
views/front/events/confirmation.html

index 760600b..af6acf7 100644 (file)
@@ -201,6 +201,7 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         $eventAmenities = array();
         $venues         = false;
         $startTimeOnly  = 0;
+        $eventCategories = [];
 
         if ( isset( $actionData['request']['member_only'] )
             && $memberOnly = filter_var( $actionData['request']['member_only'], FILTER_VALIDATE_BOOLEAN ) ) {
@@ -246,8 +247,10 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         $emailNotification = ( isset($emailInfo['email_notification']) ? $emailInfo['email_notification'] : '' );
 
         $cats = $categories->getList();
-        foreach($cats as $cat){
-            $eventCategories[] = $cat;
+        if( !empty($cats) ){
+            foreach($cats as $cat){
+                $eventCategories[] = $cat;
+            }
         }
 
         // Load recurrences class
@@ -256,13 +259,17 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         //Load Events class
         $events   = new GlmDataEvents($this->wpdb, $this->config );
         $newEvent = $events->newEntry();
-
+        
+        $pageID = get_option('glm_members_database_option_event_confirmation_id');
+        $redirect_url = get_permalink($pageID);
+        
         // if form is submitted
         if ( isset( $_REQUEST['newEvent'] ) && $_REQUEST['newEvent'] == "Add Event" ) {
 
             // Check to see if the honey pot caught spam.
             if ( isset( $_REQUEST['real_email'] ) && $_REQUEST['real_email'] ) {
-                $view = 'confirmation';
+//                $view = 'confirmation';
+                header("Location: $redirect_url"); /* Redirect browser */
             } else {
                 // parse dates and times
                 date_default_timezone_set('America/New_York');
@@ -656,8 +663,8 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                     // remove the filter to avoid conflicts
                     remove_filter( 'wp_mail_content_type', 'set_content_type' );
                 }
-
-                $view = 'confirmation';
+//              $view = 'confirmation';
+                header("Location: $redirect_url"); /* Redirect browser */
             }
         }
 
index 025bb1c..0fa332d 100644 (file)
@@ -57,5 +57,14 @@ $glmMembersEventsRequiredPages = array(
         'content' => '[glm-members-event-detail]',
         'parent' => '0',
         'underscored_title' => 'event_detail_id',
+    ),
+    'Event Confirmation' => array(
+        'title' => 'Event Confirmation',
+        'content' => '<div class="success-content row"><div class="small-12 columns" id="success">
+                     <h5> Thank you for submitting your event </h5>
+                     <p> Your submission is currently pending, please allow up to 48 hours for it to be reviewed </p>
+                     </div> </div>',
+        'parent' => '0',
+        'underscored_title' => 'event_confirmation_id',
     )
 );
index 7dde154..5038719 100644 (file)
@@ -6,10 +6,5 @@
         <p> Your submission is currently pending, please allow up to 48 hours for it to be reviewed </p>
     </div>
     </div>
-    <script>
-        jQuery(document).ready(function($){
-            console.log("test");
-        });
-    </script>
 </html>