This guide will show you how to add the email address of the author of the post containing the form as a recipient of the notification email. Add the following code to the WP theme functions.php file (or create a plugin for it).
12
3
4
5
6
7
8
9
10
11
12
13
| add_action('quform_pre_send_notification_1_1', function ($mailer) { $postId = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; $post = get_post($postId); if ($post instanceof WP_Post) { $author = get_user_by('id', $post->post_author); if ($author instanceof WP_User && Quform_Validator_Static::isValid('email', $author->user_email)) { $mailer->clearAddresses(); $mailer->addAddress($author->user_email); } } }); |
add_action('quform_pre_send_notification_1_1', function ($mailer) { $postId = isset($_POST['post_id']) ? (int) $_POST['post_id'] : 0; $post = get_post($postId); if ($post instanceof WP_Post) { $author = get_user_by('id', $post->post_author); if ($author instanceof WP_User && Quform_Validator_Static::isValid('email', $author->user_email)) { $mailer->clearAddresses(); $mailer->addAddress($author->user_email); } } });
- On line 1, replace
1_1
with the notification unique ID
Note: this code will remove the To recipient(s) that are set in the form builder, if you want to keep these recipients remove line 9.