PluginProbe
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor / 3.9.6
User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor v3.9.6
4.0.2 4.0.1 4.0.0 3.16.6 3.16.5 3.16.4 3.16.3 3.16.2 3.16.1 3.16.0 3.15.9 3.9.9 3.9.5 3.9.6 3.9.7 3.9.8 1.1.7 1.1.8 1.1.9 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 All 340 releases
profile-builder / features / email-customizer / user-email-customizer.php

user-email-customizer.php in User Profile Builder – Beautiful User Registration Forms, User Profiles & User Role Editor 3.9.6, at features/email-customizer/user-email-customizer.php

373 lines 17.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Function that creates the User Email Customizer menu
4 *
5 * @since v.2.0
6 *
7 * @return void
8 */
9 function wppb_user_email_customizer_submenu(){
10 $args = array(
11 'menu_title' => __( 'User Email Customizer', 'profile-builder' ),
12 'page_title' => __( 'User Email Customizer Settings', 'profile-builder' ),
13 'menu_slug' => 'user-email-customizer',
14 'page_type' => 'submenu_page',
15 'capability' => 'manage_options',
16 'priority' => 10,
17 'parent_slug' => 'profile-builder'
18 );
19
20 new WCK_Page_Creator_PB( $args );
21 }
22 add_action( 'admin_menu', 'wppb_user_email_customizer_submenu', 1 );
23
24 add_action( 'wck_before_meta_boxes', 'wppb_add_tabs_on_top_of_user_email_page' );
25 function wppb_add_tabs_on_top_of_user_email_page( $hookname ){
26 if( $hookname == 'profile-builder_page_user-email-customizer' ){
27
28 if( isset( $_GET['mustache_action'] ) && $_GET['mustache_action'] == 'save' ) { ?>
29 <div id="setting-error-settings_updated" class="updated settings-error notice">
30 <p><strong><?php esc_html_e( "Settings saved.", 'profile-builder' ); ?></strong></p>
31 </div>
32 <?php
33 }
34
35 wppb_generate_settings_tabs();
36 }
37 }
38
39 /* on the init hook add the mustache boxes */
40 add_action( 'init', 'wppb_user_email_customizer_add_mustache_in_backend', 11 );
41 /**
42 * Function that ads the mustache boxes in the backend for user email customizer
43 *
44 * @since v.2.0
45 */
46 function wppb_user_email_customizer_add_mustache_in_backend(){
47 if( defined( 'WPPB_PAID_PLUGIN_DIR' ) && file_exists( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) )
48 require_once( WPPB_PAID_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' );
49 elseif( file_exists( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' ) )
50 require_once( WPPB_PLUGIN_DIR . '/assets/lib/class-mustache-templates/class-mustache-templates.php' );
51
52 $fields = array(
53 array(
54 'id' => 'wppb_admin_emailc_common_settings_header', // field id and name
55 'type' => 'header', // type of field
56 'default' => __( 'These settings are also replicated in the "Admin Email Customizer" settings-page upon save.', 'profile-builder' ).' '.__( 'Valid tags {{reply_to}} and {{site_name}}', 'profile-builder'), // type of field
57 ),
58 array(
59 'label' => __( 'From (name)', 'profile-builder' ), // <label>
60 'desc' => '', // description
61 'id' => 'wppb_emailc_common_settings_from_name', // field id and name
62 'type' => 'text', // type of field
63 'default' => '{{site_name}}', // type of field
64 'desc' => '',
65 ),
66 array(
67 'label' => __( 'From (reply-to email)', 'profile-builder' ), // <label>
68 'desc' => '', // description
69 'id' => 'wppb_emailc_common_settings_from_reply_to_email', // field id and name
70 'type' => 'text', // type of field
71 'default' => '{{reply_to}}', // type of field
72 'desc' => __( 'Must be a valid email address or the tag {{reply_to}} which defaults to the administrator email', 'profile-builder' ),
73 ),
74 );
75 new PB_Mustache_Generate_Admin_Box( 'uec_common_settings', __( 'Common Settings', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', '', '', $fields );
76
77 /*
78 * Default Registration
79 */
80
81 // we format the var like this for proper line breaks.
82 $uec_default_registration = __("<h3>Welcome to {{site_name}}!</h3>\n<p>Your username is: {{username}}</p>\n", 'profile-builder' );
83 $mustache_vars = wppb_email_customizer_generate_merge_tags();
84 $fields = array(
85 array(
86 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
87 'desc' => '', // description
88 'id' => 'wppb_user_emailc_default_registration_email_subject', // field id and name
89 'type' => 'text', // type of field
90 'default' => 'A new account has been created for you on {{site_name}}', // type of field
91 ),
92 array(
93 'label' => __( 'Enable email', 'profile-builder' ), // <label>
94 'desc' => '', // description
95 'id' => 'wppb_user_emailc_default_registration_email_enabled', // field id and name
96 'type' => 'checkbox', // type of field
97 'default' => 'on',
98 ),
99 array( // Textarea
100 'label' => '', // <label>
101 'desc' => '', // description
102 'id' => 'wppb_user_emailc_default_registration_email_content', // field id and name
103 'type' => 'textarea', // type of field
104 'default' => $uec_default_registration, // type of field
105 )
106 );
107 new PB_Mustache_Generate_Admin_Box( 'uec_default_registration', __( 'Default Registration', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
108
109 /*
110 * Registration with Email Confirmation
111 */
112 // we format the var like this for proper line breaks.
113 $uec_reg_with_email_confirm = __( "<p>To activate your user, please click the following link:<br/>\n{{{activation_link}}}</p>\n<p>After you activate, you will receive another email with your credentials.</p>\n", 'profile-builder' );
114 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'email_confirmation' );
115 $fields = array(
116 array(
117 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
118 'desc' => '', // description
119 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_subject', // field id and name
120 'type' => 'text', // type of field
121 'default' => __( '[{{site_name}}] Activate {{username}}', 'profile-builder' ), // type of field
122 ),
123 array(
124 'label' => __( 'Enable email', 'profile-builder' ), // <label>
125 'desc' => '', // description
126 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_enabled', // field id and name
127 'type' => 'checkbox', // type of field
128 'default' => 'on',
129 ),
130 array( // Textarea
131 'label' => '', // <label>
132 'desc' => '', // description
133 'id' => 'wppb_user_emailc_registr_w_email_confirm_email_content', // field id and name
134 'type' => 'textarea', // type of field
135 'default' => $uec_reg_with_email_confirm, // type of field
136 )
137 );
138
139 new PB_Mustache_Generate_Admin_Box( 'uec_reg_with_email_confirmation', __( 'Registration with Email Confirmation', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
140
141 if( PROFILE_BUILDER != 'Profile Builder Free' ){
142
143 /*
144 * Registration with Admin Approval
145 */
146
147 $uec_reg_with_admin_approval = __( "<h3>Welcome to {{site_name}}!</h3>\n<p>Your username is: {{username}}</p>\n<p>Before you can access your account, an administrator needs to approve it. You will be notified via email.</p>\n", 'profile-builder' );
148 $mustache_vars = wppb_email_customizer_generate_merge_tags();
149 $fields = array(
150 array(
151 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
152 'desc' => '', // description
153 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_subject', // field id and name
154 'type' => 'text', // type of field
155 'default' => __( 'A new account has been created for you on {{site_name}}', 'profile-builder' ), // type of field
156 ),
157 array(
158 'label' => __( 'Enable email', 'profile-builder' ), // <label>
159 'desc' => '', // description
160 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_enabled', // field id and name
161 'type' => 'checkbox', // type of field
162 'default' => 'on',
163 ),
164 array( // Textarea
165 'label' => '', // <label>
166 'desc' => '', // description
167 'id' => 'wppb_user_emailc_registration_with_admin_approval_email_content', // field id and name
168 'type' => 'textarea', // type of field
169 'default' => $uec_reg_with_admin_approval, // type of field
170 )
171 );
172
173 new PB_Mustache_Generate_Admin_Box( 'uec_reg_with_admin_approval', __( 'Registration with Admin Approval', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
174
175 /*
176 * Admin Approval Notifications ( on user approval )
177 */
178 $uec_notif_approved_email = __( "<h3>Good News!</h3>\n<p>An administrator has just approved your account: {{username}} on {{site_name}}.</p>\n", 'profile-builder' );
179 $mustache_vars = wppb_email_customizer_generate_merge_tags();
180 $fields = array(
181 array(
182 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
183 'desc' => '', // description
184 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_subject', // field id and name
185 'type' => 'text', // type of field
186 'default' => __( 'Your account on {{site_name}} has been approved!', 'profile-builder' ), // type of field
187 ),
188 array(
189 'label' => __( 'Enable email', 'profile-builder' ), // <label>
190 'desc' => '', // description
191 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_enabled', // field id and name
192 'type' => 'checkbox', // type of field
193 'default' => 'on',
194 ),
195 array( // Textarea
196 'label' => '', // <label>
197 'desc' => '', // description
198 'id' => 'wppb_user_emailc_admin_approval_notif_approved_email_content', // field id and name
199 'type' => 'textarea', // type of field
200 'default' => $uec_notif_approved_email, // type of field
201 )
202 );
203
204 new PB_Mustache_Generate_Admin_Box( 'uec_notif_approved_email', __( 'User Approval Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
205
206 /*
207 * Admin Approval Notifications ( on user unapproval )
208 */
209 $uec_notif_unapproved_email = __( "<h3>Hello,</h3>\n<p>Unfortunatelly an administrator has just unapproved your account: {{username}} on {{site_name}}.</p>\n", 'profile-builder' );
210 $mustache_vars = wppb_email_customizer_generate_merge_tags();
211 $fields = array(
212 array(
213 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
214 'desc' => '', // description
215 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_subject', // field id and name
216 'type' => 'text', // type of field
217 'default' => __( 'Your account on {{site_name}} has been unapproved!', 'profile-builder' ), // type of field
218 ),
219 array(
220 'label' => __( 'Enable email', 'profile-builder' ), // <label>
221 'desc' => '', // description
222 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_enabled', // field id and name
223 'type' => 'checkbox', // type of field
224 'default' => 'on',
225 ),
226 array( // Textarea
227 'label' => '', // <label>
228 'desc' => '', // description
229 'id' => 'wppb_user_emailc_admin_approval_notif_unapproved_email_content', // field id and name
230 'type' => 'textarea', // type of field
231 'default' => $uec_notif_unapproved_email , // type of field
232 )
233 );
234
235 new PB_Mustache_Generate_Admin_Box( 'uec_notif_unapproved_email', __( 'Unapproved User Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
236
237 }
238
239
240 /*
241 * Password Reset Email
242 */
243 // we format the var like this for proper line breaks.
244 $uec_reset = __( "<p>Someone requested that the password be reset for the following account: {{site_name}}<br/>\nUsername: {{username}}</p>\n<p>If this was a mistake, just ignore this email and nothing will happen.</p>\n<p>To reset your password, visit the following address:<br/>\n{{{reset_link}}}</p>\n", 'profile-builder' );
245 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'password_reset' );
246 $fields = array(
247 array(
248 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
249 'desc' => '', // description
250 'id' => 'wppb_user_emailc_reset_email_subject', // field id and name
251 'type' => 'text', // type of field
252 'default' => __( '[{{site_name}}] Password Reset', 'profile-builder' ), // type of field
253 ),
254 array(
255 'label' => __( 'Enable email', 'profile-builder' ), // <label>
256 'desc' => '', // description
257 'id' => 'wppb_user_emailc_reset_email_enabled', // field id and name
258 'type' => 'checkbox', // type of field
259 'default' => 'on',
260 ),
261 array( // Textarea
262 'label' => '', // <label>
263 'desc' => '', // description
264 'id' => 'wppb_user_emailc_reset_email_content', // field id and name
265 'type' => 'textarea', // type of field
266 'default' => $uec_reset, // type of field
267 )
268 );
269
270 new PB_Mustache_Generate_Admin_Box( 'uec_reset', __( 'Password Reset Email', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
271
272 /*
273 * Password Reset Success Email
274 */
275 // we format the var like this for proper line breaks.
276 $uec_reset_success = __( "<p>You have successfully reset your password.</p>\n", 'profile-builder' );
277 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'password_reset_success' );
278 $fields = array(
279 array(
280 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
281 'desc' => '', // description
282 'id' => 'wppb_user_emailc_reset_success_email_subject', // field id and name
283 'type' => 'text', // type of field
284 'default' => __( '[{{site_name}}] Password Reset Successfully', 'profile-builder' ), // type of field
285 ),
286 array(
287 'label' => __( 'Enable email', 'profile-builder' ), // <label>
288 'desc' => '', // description
289 'id' => 'wppb_user_emailc_reset_success_email_enabled', // field id and name
290 'type' => 'checkbox', // type of field
291 'default' => 'on',
292 ),
293 array( // Textarea
294 'label' => '', // <label>
295 'desc' => '', // description
296 'id' => 'wppb_user_emailc_reset_success_email_content', // field id and name
297 'type' => 'textarea', // type of field
298 'default' => $uec_reset_success, // type of field
299 )
300 );
301
302 new PB_Mustache_Generate_Admin_Box( 'uec_reset_success', __( 'Password Reset Success Email', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
303
304 /*
305 * Change Email Address Request Notification
306 */
307 $admin_email = get_option('admin_email');
308
309 // we format the var like this for proper line breaks.
310 $uec_change_email_request = sprintf( __( "<h3>Hi {{username}},</h3>\n<p>There is an email address change request on {{site_name}}.</p>\n<p>To change your email address click on: {{{user_email_change_link}}}</p>\n<p>Regards,<br>\nAll at {{site_name}}<br>\n<a href=\"{{site_url}}\">{{site_url}}</a></p>", 'profile-builder' ), $admin_email );
311 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'change_email_address_request' );
312 $fields = array(
313 array(
314 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
315 'desc' => '', // description
316 'id' => 'wppb_user_emailc_change_email_address_request_subject', // field id and name
317 'type' => 'text', // type of field
318 'default' => __( '[{{site_name}}] Notice of Email Change Request', 'profile-builder' ), // type of field
319 ),
320 array(
321 'label' => __( 'Enable email', 'profile-builder' ), // <label>
322 'desc' => '', // description
323 'id' => 'wppb_user_emailc_change_email_address_request_enabled', // field id and name
324 'type' => 'checkbox', // type of field
325 'default' => 'on',
326 ),
327 array( // Textarea
328 'label' => '', // <label>
329 'desc' => '', // description
330 'id' => 'wppb_user_emailc_change_email_address_request_content', // field id and name
331 'type' => 'textarea', // type of field
332 'default' => $uec_change_email_request, // type of field
333 )
334 );
335
336 new PB_Mustache_Generate_Admin_Box( 'uec_change_email_request', __( 'Change Email Address Request Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
337
338 /*
339 * Change Email Address Notification
340 */
341 $admin_email = get_option('admin_email');
342
343 // we format the var like this for proper line breaks.
344 $uec_change_email = sprintf( __( "<h3>Hi {{username}},</h3>\n<p>This notice confirms that your email was changed on {{site_name}}.</p>\n<p>If you did not change your email, please contact the Site Administrator at %s</p>\n<p>This email has been sent to {{user_email}}</p>\n<p>Regards,<br>\nAll at {{site_name}}<br>\n<a href=\"{{site_url}}\">{{site_url}}</a></p>", 'profile-builder' ), $admin_email );
345 $mustache_vars = wppb_email_customizer_generate_merge_tags( 'change_email_address' );
346 $fields = array(
347 array(
348 'label' => __( 'Email Subject', 'profile-builder' ), // <label>
349 'desc' => '', // description
350 'id' => 'wppb_user_emailc_change_email_address_subject', // field id and name
351 'type' => 'text', // type of field
352 'default' => __( '[{{site_name}}] Notice of Email Change', 'profile-builder' ), // type of field
353 ),
354 array(
355 'label' => __( 'Enable email', 'profile-builder' ), // <label>
356 'desc' => '', // description
357 'id' => 'wppb_user_emailc_change_email_address_enabled', // field id and name
358 'type' => 'checkbox', // type of field
359 'default' => 'on',
360 ),
361 array( // Textarea
362 'label' => '', // <label>
363 'desc' => '', // description
364 'id' => 'wppb_user_emailc_change_email_address_content', // field id and name
365 'type' => 'textarea', // type of field
366 'default' => $uec_change_email, // type of field
367 )
368 );
369
370 new PB_Mustache_Generate_Admin_Box( 'uec_change_email', __( 'Changed Email Address Notification', 'profile-builder' ), 'profile-builder_page_user-email-customizer', 'core', $mustache_vars, '', $fields );
371
372 }
373