forked from arshidkv12/email-template-forminator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathemail-template-forminator.php
More file actions
40 lines (33 loc) · 1.24 KB
/
Copy pathemail-template-forminator.php
File metadata and controls
40 lines (33 loc) · 1.24 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
<?php
/**
* Plugin Name: Email Template for Forminator
*/
new EmailTemplate4Forminator;
class EmailTemplate4Forminator{
public $msg;
public $template;
public function __construct(){
add_filter('forminator_custom_form_mail_user_message', array( $this, 'user_msg'), 10, 5);
add_filter('forminator_custom_form_mail_admin_message', array( $this, 'admin_msg'), 10, 5);
add_filter('forminator_email_message', array( $this, 'email4frm_clean'));
}
public function admin_msg( $message, $custom_form, $data, $entry, $mail ){
if ( $custom_form->id === 2523 ) {
$this->template = plugin_dir_path(__FILE__) .'/template.php';
} else {
$this->template = plugin_dir_path(__FILE__) .'/user-template.php';
}
$this->msg = $message;
return $message;
}
public function user_msg( $message, $custom_form, $data, $entry, $mail ){
$this->template = plugin_dir_path(__FILE__) .'/user-template.php';
$this->msg = $message;
return $message;
}
public function email4frm_clean( $body ){
$my_template = file_get_contents( $this->template );
$body = str_replace( '{msg}', $this->msg, $my_template);
return $body;
}
}