removing php header function, adding new file for user confirmation email
authorAnthony Talarico <talarico@gaslightmedia.com>
Thu, 22 Jun 2017 15:49:00 +0000 (11:49 -0400)
committerAnthony Talarico <talarico@gaslightmedia.com>
Thu, 22 Jun 2017 15:49:00 +0000 (11:49 -0400)
setting the email function when a user submits an event, created a separate email
form view file for the user. Changing the use of php header function to redirect to
confirmation page to javascript window location function in the confirmation view file.
commented out the wp mail function for the user until it's test working fully

models/front/events/frontAdd.php
setup/requiredPages.php
views/front/events/confirmation.html
views/front/events/userEmail.html [new file with mode: 0644]

index 40d0832..2bfa618 100644 (file)
@@ -270,16 +270,17 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
         $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);
+        $confirmation_page_id = get_option('glm_members_database_option_event_confirmation_id');
+        $redirect_url = get_permalink($confirmation_page_id);
         
         // 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';
-                header("Location: $redirect_url"); /* Redirect browser */
+                $view = 'confirmation';
+    
+//                header("Location: $redirect_url"); /* Redirect browser */
             } else {
                 // parse dates and times
                 date_default_timezone_set('America/New_York');
@@ -643,9 +644,11 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                     require GLM_MEMBERS_PLUGIN_SETUP_PATH.'/standardTemplateParams.php';
 
                     $viewFile = 'front/events/ownerEmail.html';
+                    $userEmailFile = 'front/events/userEmail.html';
 
                     // Generate output from model data and view
                     $htmlMessage = $smarty->template->fetch($viewFile);
+                    $userMessage = $smarty->template->fetch($userEmailFile);
 
                     function set_content_type(){
                         return "text/html";
@@ -663,18 +666,24 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
                     $to      = $to_email;
                     $subject = 'Event Form Submission';
                     $message = $htmlMessage;
+                    $userBody = $userMessage;
                     $headers = 'From:' . $fromEmail . "\r\n" .
                                'Reply-To:' . $contactEmail;
                     $header[] = 'From:' . $fromEmail;
-                    $header[] = 'Reply-To:' . $contactEmail;
-
+                    $header[] = 'Reply-To:' . $contactEmail;    
+                    
                     wp_mail($to, $subject, $message, $header);
-
+                    
+                    $userHeader[] = 'From:' . $to[0];
+                    $userHeader[] = 'Reply-To: No-Reply@gaslightmedia.com';  
+                    
+//                    wp_mail('anthony@localhost', $subject, $userBody, $userHeader);
+                    
                     // remove the filter to avoid conflicts
                     remove_filter( 'wp_mail_content_type', 'set_content_type' );
                 }
-//              $view = 'confirmation';
-                header("Location: $redirect_url"); /* Redirect browser */
+                $view = 'confirmation';
+//                header("Location: $redirect_url"); /* Redirect browser */
             }
         }
 
@@ -684,24 +693,25 @@ class GLmMembersFront_events_frontAdd extends GlmDataEvents
 
         // Compile template data
         $templateData = array(
-            'members'        => $members,
-            'venues'         => $venues,
-            'eventAmenities' => $eventAmenities,
-            'memberManager'  => $memberManager,
-            'memberOnly'     => $memberOnly,
-            'memberContact'  => $memberContact,
-            'states'         => $this->config['states'],
-            'state_def'      => $default_state,
-            'siteBaseUrl'    => GLM_MEMBERS_EVENTS_SITE_BASE_URL,
-            'currentUrl'     => ((isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
-            'categories'     => $eventCategories,
-            'fromDate'       => $fromDate,
-            'event'          => $newEvent,
-            'permalink'      => $permalink,
-            'title'          => $title,
-            'to_email'       => $to_email,
-            'from_email'     => $fromEmail,
-            'notification'   => $emailNotification,
+            'members'           => $members,
+            'venues'            => $venues,
+            'eventAmenities'    => $eventAmenities,
+            'memberManager'     => $memberManager,
+            'memberOnly'        => $memberOnly,
+            'memberContact'     => $memberContact,
+            'states'            => $this->config['states'],
+            'state_def'         => $default_state,
+            'siteBaseUrl'       => GLM_MEMBERS_EVENTS_SITE_BASE_URL,
+            'currentUrl'        => ((isset($_SERVER['HTTP_REFERER']) && $_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : ''),
+            'categories'        => $eventCategories,
+            'fromDate'          => $fromDate,
+            'event'             => $newEvent,
+            'permalink'         => $permalink,
+            'title'             => $title,
+            'to_email'          => $to_email,
+            'from_email'        => $fromEmail,
+            'notification'      => $emailNotification,
+            'confirmation_page' => $redirect_url, 
             'mainImgUrl'     => GLM_MEMBERS_PLUGIN_MEDIA_URL . '/images/large/'
         );
 
index 0fa332d..3a1054a 100644 (file)
@@ -60,10 +60,7 @@ $glmMembersEventsRequiredPages = array(
     ),
     '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>',
+        'content' => 'Thank you for submitting your event, Your submission is currently pending, please allow up to 48 hours for it to be reviewed',
         'parent' => '0',
         'underscored_title' => 'event_confirmation_id',
     )
index 5038719..fb0beca 100644 (file)
@@ -2,9 +2,15 @@
 <html>
     <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>
+        <p> Processing Form.... </p>
     </div>
     </div>
+
+    <script>
+        jQuery(document).ready(function($){
+           var redirect_url = '{$confirmation_page}';
+           window.location.href = redirect_url;
+        });
+    </script>
 </html>
 
diff --git a/views/front/events/userEmail.html b/views/front/events/userEmail.html
new file mode 100644 (file)
index 0000000..efcbe02
--- /dev/null
@@ -0,0 +1,42 @@
+<!DOCTYPE html>
+<html>
+    <head>
+        <meta http-equiv="content-type" content="text/html;charset=utf-8">
+    </head>
+    <body>
+      <h1 id="title"> Event Submission Notification</h1>
+      
+       <table cellspacing="0" cellpadding="0" width="500" style="background: lightgrey;border:1px solid #ccc;border-collapse:collapse;">
+           <tr>
+               <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Event Name:</td>
+               <td style="width:200px;padding:5px;border:1px solid #ccc;">{$name}</td>
+           </tr>
+           <tr>
+               <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Event Start Date: </td>
+               <td style="width:200px;padding:5px;border:1px solid #ccc;"> {$startDate} </td>
+           </tr>
+           {if $endDate}
+           <tr>
+                   <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;" >Event End Date:</td>
+                   <td style="width:200px;padding:5px;border:1px solid #ccc;" >{$endDate}</td>
+           </tr>
+            {/if}
+            {if $startTime}
+                <tr>
+                     <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Event Start Time:</td>
+                       <td style="width:200px;padding:5px;border:1px solid #ccc;">{$startTime}</td>
+                </tr>
+            {/if}
+            {if $endTime}
+                <tr>
+                  <td style="font-weight:bold;width:200px;padding:5px;border:1px solid #ccc;">Event End Time:</td>
+                   <td style="width:200px;padding:5px;border:1px solid #ccc;">{$endTime}</td>
+                 </tr>
+            {/if}
+        </table>
+           
+        <div id="emailFooter">
+            <p style="margin-bottom: 0px;">Thank you for submitting your event, please allow up to 48 hours for the event to be reviewed.</p>
+        </div>
+    </body>
+</html>
\ No newline at end of file