'use' => 'a'
),
+ // Email Notification Message
+ 'email_notification' => array(
+ 'field' => 'email_notification',
+ 'type' => 'text',
+ 'required' => false,
+ 'use' => 'a'
+ ),
// Event Declined Message
'declined_message' => array(
'field' => 'declined_message',
// Load Events Management Settings data
$eventsManagementSettings = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."management WHERE id = 1", ARRAY_A );
+// Grab the new email_notification to_email and from_email to add to these (override)
+$emailNotifications = $wpdb->get_row( "SELECT * FROM ".GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX."email_notifications WHERE id = 1", ARRAY_A );
+if ( $eventsManagementSettings ) {
+ $eventsManagementSettings = array_merge( $eventsManagementSettings, $emailNotifications );
+}
+
unset($eventsManagementSettings['id']);
function glmMembersRegisterEvents($addOns) {
$haveEvent = false;
$event = false;
}
-
+
$view = 'edit';
break;
} else if ( isset( $_REQUEST['searched'] ) && !isset( $_REQUEST['prevStart'] ) ) {
unset( $_SESSION['search']['prevStart'] );
}
-
+
// Check for Archived filter
if (isset($_REQUEST['filterArchived']) && $_REQUEST['filterArchived'] == 'on') {
$filterArchived = true;
$start = $newStart;
}
}
-
+
if( isset($_SESSION['search']['pageSelect']) ){
// If request is for Next
if ($_SESSION['search']['pageSelect'][0] == 'N') {
}
-
+
}
// DECLINED & APPROVED EVENT EMAIL FUNCTIONALITY ///////
- $sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "email_notifications";
- $email_notifications = !empty($this->wpdb->get_results($sql, ARRAY_A)) ? $this->wpdb->get_results($sql, ARRAY_A)[0] : false;
+ //$sql = "SELECT * FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "email_notifications";
+ //$email_notifications = !empty($this->wpdb->get_results($sql, ARRAY_A)) ? $this->wpdb->get_results($sql, ARRAY_A)[0] : false;
+ $email_notifications = $this->config['settings'];
$from_email = $email_notifications ? $email_notifications['from_email'] : false;
// echo '<pre>', print_r($event), '</pre>';
-
+
$to_email = (isset($event['fieldData']['admin_email']) ? $event['fieldData']['admin_email'] : '' );
$event_title = (isset($event['fieldData']['name']) ? $event['fieldData']['name'] : '' );
$admin_name = (isset($event['fieldData']['admin_name']) ? $event['fieldData']['admin_name'] : '' );
$event_intro = (isset($event['fieldData']['intro']) ? $event['fieldData']['intro'] : '' );
$site_name = get_bloginfo( 'name' );
-
+
$header[] = "From: $site_name <$from_email>";
$header[] = 'Reply-To: ' . $from_email;
$header[] = "Return-Path: $from_email";
$message .= "Event Name: " . $event_title . "<br>";
$message .= "Event Description: $event_intro<br>";
$message .= "Contact Name: $admin_name<br><br>";
-
-
+
+
if( $old_event_status === '20' && $current_status === '10' ) {
$subject = 'Event Approved';
$message .= $email_notifications['approved_message'];
remove_filter( 'wp_mail_content_type', 'set_content_type' );
// END DECLINED & APPROVED EVENT EMAIL FUNCTIONALITY ////////
-
+
if (!$this->config['settings']['event_default_state']) {
$this->config['settings']['event_default_state'] = $this->config['settings']['default_state'];
}
$view = 'frontAdd';
// populate category dropdown
$categories = new GlmDataEventsCategories( $this->wpdb, $this->config );
- $emailInfo = new GlmDataEventsManagement( $this->wpdb, $this->config );
- $emailInfo = $emailInfo->getEntry(1);
+ //$emailInfo = new GlmDataEventsManagement( $this->wpdb, $this->config );
+ //$emailInfo = $emailInfo->getEntry(1);
+ // Get email setting from config['settings']
+ $emailInfo = $this->config['settings'];
+
// get and validate recipient email address, put into an array to pass to wp_mail
$toEmail = $emailInfo['to_email'];
// $siteName = get_bloginfo('name');
// return $siteName;
// }
-//
-// // Send confirmation email to the admin, set the content type to allow html by using this filter
- $sql = "SELECT to_email, from_email FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "email_notifications";
- $email_addresses = $this->wpdb->get_results($sql, ARRAY_A)[0];
-
+//
+// // Send confirmation email to the admin, set the content type to allow html by using this filter
+ //$sql = "SELECT to_email, from_email FROM " . GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX . "email_notifications";
+ //$email_addresses = $this->wpdb->get_results($sql, ARRAY_A)[0];
+
add_filter( 'wp_mail_content_type', 'set_content_type' );
- $site_name = get_bloginfo('name');
- $adminEmail = $email_addresses['to_email'];
- $fromEmail = $email_addresses['from_email'];
- $subject = 'Event Form Submission';
+ $site_name = get_bloginfo('name');
+ $adminEmail = $emailInfo['to_email'];
+ $fromEmail = $emailInfo['from_email'];
+ $subject = 'Event Form Submission';
+
+ $message = $htmlMessage;
+ $userBody = $userMessage;
- $message = $htmlMessage;
- $userBody = $userMessage;
+ $header[] = "From: $site_name <$fromEmail>";
+ $header[] = 'Reply-To:' . $userEmail;
- $header[] = "From: $site_name <$fromEmail>";
- $header[] = 'Reply-To:' . $userEmail;
-
wp_mail($adminEmail, $subject, $message, $header);
-
+
// send a copy to the user submitting the email, using different headers and email template file
$userHeader[] = "From: $site_name <$fromEmail>";
$userHeader[] = 'Reply-To: No-Reply@gaslightmedia.com';
-
+
if(wp_mail($userEmail, $subject, $userBody, $userHeader)){
} else {
} );
// check the settings to see if members are allow to manage events
-$memberEventsAllowed = $this->config['settings']['member_events_allowed'];
+$memberEventsAllowed = isset( $this->config['settings']['member_events_allowed'] )
+ ? $this->config['settings']['member_events_allowed']
+ : true;
if ( $memberEventsAllowed ) {
add_filter(
approved_message TEXT NULL, -- Event approved message
to_email TINYTEXT NULL, -- To Email Address
from_email TINYTEXT NULL, -- From Email Address
+ email_notification TEXT NULL, -- Email notification message
PRIMARY KEY (id)
);
// Update new email_notification table with the old to from email from management
$managementOptions = $wpdb->get_results(
- 'SELECT id, to_email, from_email FROM '.GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'management where id = 1',
+ 'SELECT * FROM '.GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'management where id = 1',
ARRAY_A
);
if ($managementOptions && count($managementOptions) > 0) {
$wpdb->update(
GLM_MEMBERS_EVENTS_PLUGIN_DB_PREFIX.'email_notifications',
array(
- 'to_email' => $i['to_email'],
- 'from_email' => $i['from_email']
+ 'to_email' => $i['to_email'],
+ 'from_email' => $i['from_email'],
+ 'email_notification' => $i['email_notification']
),
array( 'id' => $i['id'] ),
- array( '%s', '%s' ),
+ array( '%s', '%s', '%s' ),
array( '%d')
);
}
----
UPDATE {prefix}management SET member_events_allowed = 1 WHERE id = 1;
+
+----
+
+-- new field in email_notifications
+ALTER TABLE {prefix}email_notifications ADD COLUMN email_notification TEXT NULL; -- Email notification message
{include file='admin/settings/header.html'}
<!-- Add Categories Button and Dialog Box -->
-
+
<form action="{$thisUrl}?page={$thisPage}" method="post" enctype="multipart/form-data">
<input type="hidden" name="glm_action" value="emailNotifications">
{if $email_settings}
<div class="email-notification-info">This email address is what recipient will receive from the accept/decline email message that is automatically sent once action has been taken on event record.</div>
</div>
</div>
+ <div class="glm-row">
+ <div class="glm-small-12 glm-medium-3 glm-column email-notification-label"> Email Notification Message </div>
+ <div class="glm-small-12 glm-medium-9 glm-column email-notification-editor">
+ {php}
+ wp_editor('{if $email_settings} {$email_settings.email_notification|escape:quotes} {/if}', 'glm_notification', array(
+ 'media_buttons' => false,
+ // 'quicktags' => false,
+ // 'wpautop' => false, NOTE: Dont's use. Problem when numerous spaces before text.
+ 'textarea_name' => 'email_notification',
+ 'editor_height' => 300, // Height in px, overrides editor_rows
+ // 'textarea_rows' => 8
+ ));
+ {/php}
+ </div>
+ </div>
<div class="glm-row">
<div class="glm-small-12 glm-medium-3 glm-column email-notification-label"> Declined Message </div>
<div class="glm-small-12 glm-medium-9 glm-column email-notification-editor">
<script type="text/javascript">
jQuery(document).ready(function($) {
-
+
});
</script>
{include file='admin/footer.html'}