Skip Navigation

[Resolved] Respond to a post by e-mail

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 6 replies, has 2 voices.

Last updated by Luo Yang 6 years, 5 months ago.

Assisted by: Luo Yang.

Author
Posts
#1088605
ReactToContactSubmission.png

This post is related to another post: https://toolset.com/forums/topic/bind-a-cpt-to-multiple-users-and-show-entrys-for-bound-users/

First i'll start with a little recap:
I have 4 CPT's:
- Engineer
- Places
- Contact Submission
- Contact React

An Engineer post is programmatically created when a user creates an account through a custom registration form.
The places CPT is filled with place names that i've imported
The Contact Submission has a m2m relation with Places. I have created an post form on which quests on my website could submit a Contact Submission.
An Engineer can connect to multiple places and only sees submissions that contain places that they are connected to.

Engineers only have front-end access, they are not allowed in the wp-admin.

I want to establish the following functionality, and i don't really know how:
The engineer must have the ability to respond to a contact submission.
This response has to be connected to the engineer.
The guest who placed the Contact Submission has to recieve the Contact React by e-mail when the engineer sends the response and the Contact React must be saved in the WordPress database.

In technical terms it will probably be as follows (i guess):
There must be a relationship between the created Contact React and the Engineer.
After pressing the button 'Respond to contact entry', the post form must receive data from the contact submission, such as the e-mail address of the website visitor who submitted the contact submission.
when the engineer has finished filling out the Contact React form and presses the 'Send and Save' button, an e-mail with the content must be send to the website visitor and the data must be saved to the Contact React cpt.
After sending and saving the Contact React, the CURRENT engineer can't respond anymore. Other engineers can still respond.

I've added an image with mockups to clarify some things, because my English isn't that good..

I hope you can help me with this.

#1089232

Hello,

In your case, I suggest you try these:
1) Setup M2M relationship between post types "Engineer" and "Places",
2) Setup O2M relationship between post types "Contact Submission" and "Contact React",
3) Each "Engineer" post's author is different "Engineer" user.

So for the "Engineer" user, in a single "places" post, you can create a post view, query "Engineer" posts, filter by:
1) query the related "Engineer" posts
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

2) post's author is current logged-in user
https://toolset.com/documentation/user-guides/filtering-views-query-by-author/

If there is any result display below child view

3) Child view query the related "Contact Submission" posts
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/#displaying-many-related-items

If there is any related "Contact Submission" post, display a post form for creating related "Contact React" post
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

Then the "Engineer" user will be able to "have the ability to respond to a contact submission."

Each "Contact React" post's author is different "Engineer" user, so this response has to be connected to the engineer.

When "Engineer" user submit the "Contact React" post form, you can use some custom codes to send an email notification to the "Contact Submission" post author or email address field:

More help:
https://toolset.com/documentation/programmer-reference/cred-api/#cred_notification_recipients
See similar thread:
https://toolset.com/forums/topic/cred-notification-to-email-from-parent-post-field-no-longer-working-after-types-3-0-update/

#1089524

Dear Luo,

Thank you for your quick response.

I don't really understand what you mean.

At this point i already have a m2m relationship between the cpt places and engineers.
My view shows all the Contact Submissions that are linked to the specific engineer.
Christian Cox helped me set all of this up.
From this view, i want to make it possible for the engineer to open a Contact submisson and see all the details of that Contact Submission.
Underneath the details he must be able to respond via a button. When the engineer presses this button he will then go to a new page to send a Contact React.

For Now I have made an o2m relationship between "Contact Submission" and "Contact React", but i don't really know what to do next.

#1090042

Q1) From this view, i want to make it possible for the engineer to open a Contact submisson and see all the details of that Contact Submission.

You just need to display link of the "Contact submisson" post for the engineer users, to setup the post link, please see our document:
hidden link

engineer user click the link, redirect him to the single "Contact submisson" post.

Q2) Underneath the details he must be able to respond via a button. When the engineer presses this button he will then go to a new page to send a Contact React.

Since there is O2M relationship between post type "Contact Submission" and "Contact React",
in the single "Contact submisson" post, you can display a post form for creating child "Contact React" post, see our document:
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/

if you don't want to display the parent selector, please check section "Creating forms when a parent post is preselected" of above document.

#1093185
Problem.PNG

Thank you Luo Yang,

I've added the wpv-post-link to my Contact Submissions view and made single page for the Contact Submissions.
I've also created the Contact React post and added the relation to the form.

Strange thing is that my dropdown field doesn't show any relation whatsoever. (see attachment)
Do you have any idea how i can fix this?

Q2) Underneath the details he must be able to respond via a button. When the engineer presses this button he will then go to a new page to send a Contact React.

Since there is O2M relationship between post type "Contact Submission" and "Contact React",
in the single "Contact submisson" post, you can display a post form for creating child "Contact React" post, see our document:

#1093209

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?

#1093653

I assume the original question of this thread is resolved, for the new questions, please check the new thread:
https://toolset.com/forums/topic/add-a-function-to-e-mail-the-content-of-the-contact-react-when-the-user-presses-submit/