emails.php
4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
<?php
/**
* Understrap emails
*
* @package Understrap
*/
// Exit if accessed directly.
add_filter( 'cf7_2_post_status_wpsl_stores', 'publish_new_wpsl_stores',10,3);
/**
* Function to change the post status of saved/submitted posts.
* @param string $status the post status, default is 'draft'.
* @param string $ckf7_key unique key to identify your form.
* @param array $submitted_data complete set of data submitted in the form as an array of field-name=>value pairs.
* @return string a valid post status ('publish'|'draft'|'pending'|'trash')
*/
function publish_new_wpsl_stores($status, $ckf7_key, $submitted_data){
$email = $submitted_data['your-email'];
$subject = 'WYN Important Registration Information';
$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
$message = file_get_contents(get_site_url().'/wp-content/themes/understrap-child/inc/Registration-Confirmation.html', false, stream_context_create($stream_opts));
$headers_customer = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $email , $subject, $message, $headers_customer);
return 'draft';
}
add_action('publish_wpsl_stores','send_notification_for_publish_project',10,1);
function send_notification_for_publish_project( $post_id ) {
$notification_sent = get_post_meta($post_id, 'notification_sent_for_publish_project', 1);
if($notification_sent != 1){
update_post_meta($post_id, 'notification_sent_for_publish_project', true);
update_post_meta($post_id, 'wpsl_country', 'CA');
delete_autoload_map_transient();
$email = get_post_meta($post_id, 'wpsl_email', true);
$subject = 'WYN Registration Aproved';
$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
$message = file_get_contents(get_site_url().'/wp-content/themes/understrap-child/inc/Registration-Acceptance.html', false, stream_context_create($stream_opts));
$headers_customer = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $email , $subject, $message, $headers_customer);
}
}
add_action( 'trash_wpsl_stores', 'send_notification_for_delete_project' ,10,1);
function send_notification_for_delete_project( $post_id ) {
$notification_sent = get_post_meta($post_id, 'notification_sent_for_delete_project', 1);
if($notification_sent != 1){
update_post_meta($post_id, 'notification_sent_for_delete_project', true);
$email = get_post_meta($post_id, 'wpsl_email', true);
$subject = 'WYN Registration Denied';
$stream_opts = [
"ssl" => [
"verify_peer"=>false,
"verify_peer_name"=>false,
]
];
$message = file_get_contents(get_site_url().'/wp-content/themes/understrap-child/inc/Registration-Denied.html', false, stream_context_create($stream_opts));
$headers_customer = array('Content-Type: text/html; charset=UTF-8');
wp_mail( $email , $subject, $message, $headers_customer);
}
}
function send_planner_email($data)
{
$name = $data['name'];
$email = $data['email'];
$phone = $data['phone'];
$panner_id = $data['broker_id'];
if($email =="" || $name =="" || $phone =="" ){
exit;
}
if(strpos($email, 'tenzing') !== false || $_SERVER['HTTP_HOST'] !="yournumbers.ca") {
$to = 'support@gotenzing.com';
} else {
$to = get_post_meta($panner_id, 'wpsl_email', true);
}
$subject = 'Request for Customer Contact from The Commonwell';
$headers = array('Content-Type: text/html; charset=UTF-8');
$body = "<h1 class='clear-both is-h1'>You're in demand! ".get_the_title($panner_id)."</h1>
<div class=' f-16'>A visitor to The yournumber.ca has requested information from you and to start the quote process. That's awesome and good luck! Please reach out to the person listed below within 48 hours. </div>
<table class=' f-16'><col width='200'></tr><tr><td>NAME:</td><td>" . $name . "</td></tr><tr><td>EMAIL:</td><td>" .$email . "</td></tr><tr><td>PHONE NUMBER:</td><td>" . $phone . "</td></tr><tr><td>POSTAL CODE:</td></tr></table><br/><br/>";
wp_mail($to, $subject, $body, $headers);
$to_customer = $data['email'];
$subject_customer = 'Contact Request Confirmationl';
$headers_customer = array('Content-Type: text/html; charset=UTF-8');
$body_customer = "<h1 class='clear-both is-h1'>Thanks for your information request.</h1>
<div class=' f-16'>We received your request for more information about. </div>";
wp_mail($to_customer, $subject_customer, $body_customer, $headers_customer);
}