Skip Navigation

[Resolved] Add a function to e-mail the content of the Contact React when the user presses Submit

This thread is resolved. Here is a description of the problem and solution.

Problem:

And is there a way to programmatically add a function to e-mail the content of the Contact React when the user presses Submit?

Solution:

Since there is O2M relationship between post types "Contact Submission" and "Contact React", so when user create new "Contact React" with Toolset form, you can try this:

1) Create a view to retrieve the related "Contact Submission" post information

2) Display above view in the Email notification content

Relevant Documentation:

https://toolset.com/documentation/user-guides/automated-email-notifications-with-cred/

This support ticket is created 6 years, 5 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Hong_Kong (GMT+08:00)

This topic contains 5 replies, has 2 voices.

Last updated by benv-2 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1093652

The issue in the previous post is resolved!

And is there a way to programmatically add a function to e-mail the content of the Contact React when the user presses Submit?

I want to e-mail the content of Content React to the e-mail adres i keep in the Contact Submission? And can i retrieve this e-mail through the o2m relationship?

Could you show me a code snippet or something to make this?

#1093655

Hello,

Since there is O2M relationship between post types "Contact Submission" and "Contact React", so when user create new "Contact React" with Toolset form, you can try this:
1) Create a view to retrieve the related "Contact Submission" post information
2) Display above view in the Email notification content
https://toolset.com/documentation/user-guides/automated-email-notifications-with-cred/

#1097386

Dear Luo,

I've tried your method to add a view, and i've tried the method to add the e-mail field to my Contact React content template (<p>[types field="contact-submission-email" id="$parent-contact-submission"][/types]</p>), which shows the child-page.

Both don't work. My view shows No records found and my types field shows nothing on the child-page.

Do you have any clue how i can resolve this?

#1097396
parent-child-fields-issue.png

For more clarification, i've made screenshot with some debuggin info (see attachment)

In the attachment you can see that the ID's don't relate to each other..

#1098403

please provide database dump file(ZIP file) of your website, also point out the problem page URL and form URL, I need to test and debug it in my localhost, thanks
https://toolset.com/faq/provide-supporters-copy-site/

#1103652

I've got this working!
I've modified my functions.php like:

add_filter('cred_notification_recipients', 'modify_recipients', 10, 4);
function modify_recipients($recipients, $notification, $form_id, $post_id) {
    // Check notification name matches target notification
    if ( isset($notification['name']) && 'Mail of engineer' == $notification['name'] ) {
        // Add email recipient
        $parent_id = toolset_get_related_post( $post_id, 'offer-request-offer-send', 'parent');
        $email_of_requester = get_post_meta($parent_id, 'wpcf-bbgt-offer-request-email', true);
        $recipients[] = array(
            'to'        =>  'cc',
            'address'   => $email_of_requester ,
            'name'      =>  '',
            'lastname'  =>  ''
            );
    }
return $recipients;
}

The $parent_id = toolset_get_related_post( $post_id, 'offer-request-offer-send', 'parent'); refers to the relationship slug

Thank you for your help!