Skip Navigation

[Résolu] Send related posts to Forms notification

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
We want to send data about related posts of the currently edited/crated one in a Toolset forms' notification.

Solution:
You can create a View and query the Post Type you want to send in the Notification.
Set a Query filter in the View to get posts related to the one passed in the ShortCode attribute you choose.
Insert that view to the Forms notification and as ShortCode attribute of the post that you want related posts of use %%POST_ID%%.

This Toolset Forms placeholder makes sure the ID of the post you currently edit is used in the View Query to get related posts of.
So the notification will show related posts of that post you edited with Forms

This support ticket is created Il y a 4 années et 7 mois. 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

Marqué : 

This topic contains 15 réponses, has 2 voix.

Last updated by Laura Il y a 4 années et 7 mois.

Assisted by: Beda.

Auteur
Publications
#1334087

How to send all information in one email or document?

I have a CPT 'jobs' that has a repeating field group 'rooms' . I need to find someway to send all of this information the main 'job' with all of its 'rooms' data to an email or maybe a way to have a document/file created that can then be sent in email? OR can be stored somewhere where the user can go retrieve it?

I just don't know where to start trying to figure out how to do this... very open to suggestions.
thank you!

#1334095

Hi Laura, let me see if I understand you correctly.

1. You have a Custom Post Jobs, which is manipulated (created or edited) thru Toolset Forms
2. You have a repeating field attached to that Post Type, which can be added in the same Toolset Form when manipulating the Post

Or, do you have Repeatable Field Groups?

The difference is, repeating fields are "just" custom fields, they could be sent in the same notification as you use for the Toolset Form that manipulates the post, by inserting the adequate ShortCode for the repeating Field, eventually with a separator.
Repeatable field Groups instead require a whole own Toolset Form to even be created or edited in the Front end.
This means, while you manipulate the "main" Job post, you cannot manipulate the belonging Repeatable Field Groups.

It should, however, be possible, to send Repeatable Field groups in an EDIT Toolset Form, this because there would be an existing Job Post with existing Repeatable Field Groups, which could be grouped in a View, and that View inserted in the Notifications would produce the content required.

I have a hunch that you mean repeatable field groups.

Can you elaborate on the steps you took and what the final goal is, so I can then propose an adequate solution?
Screenshots or direct links to where you see what or want to do what can be helpful.
I activated a private section in the next reply for any such data to be shared privately.

Thanks!

#1335873

UPDATE: ok, I was able to create a view and send the job and all its rooms using an edit form as you suggested. BUT, wondering if it might be possible to streamline this for the users. Right now the process would be they enter a new job and enter all the rooms and then they would have to go to the edit form in order to have the email sent even if they do not need to edit the data.

What I am hoping we can do is possibly add another "button"to the repeatable fields group besides the "submit" (Add Room) button. The button could be "Job Completed" button that the user would click on instead of the "Add Room" submit button once they have finished adding ALL the rooms for that job. Then this "Job Completed" button could somehow go get the job data and all its rooms and send an email to a specific user. Is this possible somehow?

Thanks!

#1336373

Great, I see you were able to implement the solution according to my suggestion - now all it takes is a smart workflow.
This needs to be done by not letting the user see what they do, so the workflow becomes natural to them

For example, a workflow saying "Add your Job", "Add Rooms to your Job", "Are you done? Publish!" could solve the issue, where you use "Are you done? Publish!" as a link to a form which in fact is nothing else but the edit form you use for the notification.

There is no way to avoid this, because on the last form (which adds Repeatable Field Groups) you cannot hook any code (these forms have no API), so you cannot gather all data there and send the notification with code - which is even difficult with "normal" forms that have an API.

I'd create a Page to add the "Add Job Form".
Then, that form redirects to the page where you add Repeatable Fields (Jobs).
In that form display, the "Done? Publish" link, after the Submit button of the Repeatable field Group.
From there the user is lead to the Job, and unconsciously (or maybe you even let them review once again) submits the email all at once.

#1336751

Thank YOU! Ok, I have those pages created as you suggested for the Job and one for the Repeatable Fields Group...
I not quite clear on the "link" where should that link go to?

Just so you know I have "Edit" links for both forms on the display jobs page per customer request to be able to update/change existing jobs and rooms. Is this where that "link" should go to?

#1337439

Well, in a place where you find suitable for the user to find it, and according to your workflow.

Let's say you placed the Create Job Form on Page "Add Job", which once that form is submitted leads to the form that lets users add rooms to this job - in that very form of Rooms you add a link, that says "Done? Publish everything"
Clicking there takes the user away from the form/page and leads to the edit form to publish everything.

The user sees this link basically only when adding new roos, as that is the only moment they might need to "send the emails", which in fact will simply be to "edit the job" again.

#1337649

so that link to the edit form.. should that be sending users to a page that has the edit form short code on it? then they would submit that form? is that correct?

#1337653

because the edit form link is not available from within a toolset form? so wondering how to do that?

#1337665

Not the Edit Form link! A simple HREF. I am sorry I didn't explain this, I assumed it obvious but it's far from it.

You'd create a a href link, and place that inside the Form that makes the rooms.

Depending on where you want the user to "finalize" his Job (and hence send the mail) you link to that page, eventually passing some URL parameters to edit the correct post if the form is on a single page!
Or, you lead to the single post and let them "edit" the post there (a button that says "publish)

Please let me know if I can help you set up an example of this. Maybe we can set up an example together on a staging site?
Maybe we can use this one?
https://toolset.com/forums/topic/send-related-content-prf-rfg-relationships-in-notifications-of-main-parent-post-using-toolset-forms/#post-1334327

#1337671

As a href link.
I elaborate this above.

A href link is an HTML link
It looks like this:
<a href="hidden link">click herea</a>
[/php]

You can insert this using an HTML cell for example, in the form
It can redirect to the same page where your form edit button is, or to the post itself.

You can make the URL dynamic with ShortCodes, like passing a post ID shortcode as URL parameter, so to lead to the correct page with URL parameter to edit that post passed in it.
I can help with this, but would need your permission to do so on the site and some links as of where you insert what.

Thanks!

#1337673

Yes! you can use that site! it is 6am here and I need to start driving to work. but you are free to use that site you mentioned ... it is a staging site. then I can see how you did it when I get to work

#1337745

You seem to start here hidden link with adding a new job.
There the user adds all data of the job.

I see you already named that submit button to "Add Rooms", which smartly saves the post but redirects to add Rooms belonging to that new Job.
Submitting a new Job leads the user to hidden link, where the form to add Rooms is present

What this form misses is the selector for the "parent" post, so the post to which the rooms belong to, the just created Job.
I see you hide that field with display:none;. Note that if it's hidden, the created repeatable field item won't be assigned to any post.
I've made it visible, so the user can add rooms to his job.
You could alternatively hide it and populate it with the [cred_field field='@rooms-rfg.parent' class='form-control' output='bootstrap' select_text='--- not set ---' author='$current' value='default' urlparam='by_url_param'] (URL Parameter) but that requires a link to this page already passing the URL param, which we do not have at this moment)

Now, this Form can be submitted as many times the user needs to add a Room, so he will never navigate away from here on its own.
This is where we place our link leading to "Done? Publish".
So the Form hidden link needs to be edited, and an HREF inserted somewhere in the form.
I did that with <a href="">I am done, Publish this all</a>

Then I completed the href part with the URL I want the user to be redirected to when they click that link.
We want them now to reach the Edit Form for the Job they created, so they can send the notification.

The easiest is to lead them to a static page "publish my stuff"
In there a View displays all the Jobs of the user.
hidden link
That View displays also a publish button form for each post.

Now, since you have set up all fields as required, you cannot create a form for Jobs without those fields, but you could hide them with HTML /CSS here hidden link
Or make them not required in Types.

Then finally you will have only a "publish" button on the hidden link page.
Your notifications should all live in the last form mentioned here.

Most is set up already, it can of course (and should) be adapted and adjusted + finetuned now.

#1337937

Thanks, There are a couple of problems I found:

1. Would it be possible to ONLY show the one job the user just entered instead?:
The easiest is to lead them to a static page "publish my stuff"
In there a View displays all the Jobs of the user.
hidden link
That View displays also a publish button form for each post.

2. When I tested this I need to have all the fields and all rooms for that ONE job sent in the notification email:
I added all the Job fields to the email and used a view: [wpv-view name="email-rooms-of-a-job" cached="off"]
to include all the Rooms of that job. BUT, the problem is I'm getting every room for every job for that user... See email excerpt below:

DUMMY_POST_TITLE - 2019-09-11 10:25:06 -
Inbox
x

Staff staff@moldtestcompany.com via managedcloudhostingemail.com
10:25 AM (44 minutes ago)
to me

Your Job information for has been updated successfuly on .

Thank you,

Staff at Mold Test Company

===================================================
Job Post ID: Job Title:

Name:
Email:
Address:
,
Phone:
Date of Inspection:
Ownership: Job Type:
Inspector Name:
Inspector Company:
If different from above to contact with results:
Age of Property:
Square Footage:
Notes:
External Image of Property:

Chain of Custody:

ROOMS/LOCATION
Location/Room: Basement
Temp: 65
Humidity: 40
Co2: 15
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Attic
Temp: 85
Humidity: 40
Co2: 5
Media Used: Air-O-Cel
Notes:
testing

Image of Room:
Location/Room: test
Temp: 22
Humidity: 22
Co2: 22
Media Used: Air-O-Cel
Notes:
Image of Room:
Location/Room: Attic
Temp: 85
Humidity: 40
Co2: 15
Media Used: Bulk
Notes:
test

Image of Room:
Location/Room: LivingRoom
Temp: 78
Humidity: 65
Co2: 15
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Room1
Temp: 85
Humidity: 50
Co2: 25
Media Used: Bulk
Notes:
test

Image of Room:
Location/Room: Room2
Temp: 85
Humidity: 40
Co2: 15
Media Used: Vacuum
Notes:
test

Image of Room:
Location/Room: Room3
Temp: 85
Humidity: 40
Co2: 15
Media Used: Myco
Notes:
test

Image of Room:
Location/Room: Room2
Temp: 85
Humidity: 65
Co2: 15
Media Used: Tape
Notes:
fszf

Image of Room:
Location/Room: Attic
Temp: 85
Humidity: 70
Co2: 15
Media Used: Myco
Notes:
test

Image of Room:
Location/Room: Basement
Temp: 78
Humidity: 40
Co2: 15
Media Used: Bulk
Notes:
test

Image of Room:
Location/Room: Bathroom
Temp: 85
Humidity: 40
Co2: 15
Media Used: Bulk
Notes:
test

Image of Room:
Location/Room: LivingRoom
Temp: 85
Humidity: 65
Co2: 5
Media Used: Swab
Notes:
test

Image of Room:
Location/Room: Bathroom
Temp: 78
Humidity: 70
Co2: 15
Media Used: Tape
Notes:
test

Image of Room:
Location/Room: LivingRoom
Temp: 85
Humidity: 65
Co2: 25
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Bathroom
Temp: 85
Humidity: 50
Co2: 5
Media Used: Swab
Notes:
test

Image of Room:
Location/Room: Attic
Temp: 95
Humidity: 65
Co2: 25
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Bathroom
Temp: 78
Humidity: 65
Co2: 5
Media Used: Tape
Notes:
test

Image of Room:
Location/Room: LivingRoom
Temp: 85
Humidity: 50
Co2: 25
Media Used: Swab
Notes:
test

Image of Room:
Location/Room: Room2
Temp: 55
Humidity: 35
Co2: 5
Media Used: Air-O-Cel
Notes:
Testing the Complete Job? link.....

Image of Room:
Location/Room: Basement
Temp: 85
Humidity: 40
Co2: 25
Media Used: Swab
Notes:
tst

Image of Room:
Location/Room: Bathroom
Temp: 85
Humidity: 65
Co2: 5
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Attic
Temp: 95
Humidity: 65
Co2: 15
Media Used: Swab
Notes:
test

Image of Room:
Room Image
Location/Room: Basement
Temp: 85
Humidity: 50
Co2: 15
Media Used: Tape
Notes:
test

Image of Room:
Room Image
Location/Room: Attic
Temp: 95
Humidity: 65
Co2: 25
Media Used: Swab
Notes:
test

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 95
Humidity: 50
Co2: 25
Media Used: Swab
Notes:
test

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 65
Humidity: 40
Co2: 15
Media Used: Air-O-Cel
Notes:
testing form noticfications

Image of Room:
Room Image
Location/Room: Bedroom-2
Temp: 75
Humidity: 50
Co2: 10
Media Used: Myco
Notes:
Testing....

Image of Room:
Room Image
Location/Room: Attic
Temp: 85
Humidity: 70
Co2: 15
Media Used: Air-O-Cel
Notes:
Adding new room to existing Job

Image of Room:
Room Image
Location/Room: Hall
Temp: 65
Humidity: 30
Co2: 10
Media Used: Tape
Notes:
Add new room to existing Job CPT

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 75
Humidity: 30
Co2: 5
Media Used: Bulk
Notes:
rm2 bathroom - Edited on Sep 5 2019

Image of Room:
Room Image
Location/Room: Livingroom
Temp: 85
Humidity: 50
Co2: 14
Media Used: Swab
Notes:
rm1 livingroom

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 85
Humidity: 50
Co2: 14
Media Used: Swab
Notes:
rm1

Image of Room:
Room Image
Location/Room: Bedroom-2
Temp: 75
Humidity: 20
Co2: 14
Media Used: Swab
Notes:
rm2

Image of Room:
Room Image
Location/Room: Bedroom-1
Temp: 85
Humidity: 50
Co2: 5
Media Used: Swab
Notes:
rm1

Image of Room:
Location/Room: Bedroom 2
Temp: 29
Humidity: 183
Co2: 281
Media Used: Air-O-Cel
Notes:
test

Image of Room:
Location/Room: Bedroom 1
Temp: 79
Humidity: 77
Co2: 190
Media Used: Tape
Notes:
Muggy room

Image of Room:
Location/Room: LivingRoom
Temp: 85
Humidity: 35
Co2: 25
Media Used: Air-O-Cel
Notes:
rm1 - edit add image

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 85
Humidity: 50
Co2: 25
Media Used: Swab
Notes:
test room1

Image of Room:
Room Image
Location/Room: Basement
Temp: 65
Humidity: 65
Co2: 15
Media Used: Swab
Notes:
test.....

Image of Room:
Room Image
Location/Room: Basement
Temp: 55
Humidity: 50
Co2: 14
Media Used: Air-O-Cel
Notes:
Testing.....

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 85
Humidity: 50
Co2: 5
Media Used: Bulk
Notes:
test

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 85
Humidity: 65
Co2: 15
Media Used: Swab
Notes:
test

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 65
Humidity: 40
Co2: 5
Media Used: Swab
Notes:
testing

Image of Room:
Room Image
Location/Room: Bedroom-2
Temp: 85
Humidity: 30
Co2: 4
Media Used: Air-O-Cel
Notes:
n fej hjnti [htji0 jhit4 [hjjhit4 0hjti jhti[ hjti0[ jhit hujti hjit2[

Image of Room:
Room Image
Location/Room: Bedroom-1
Temp: 65
Humidity: 25
Co2: 7
Media Used: Air-O-Cel
Notes:
testing.....

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 85
Humidity: 50
Co2: 10
Media Used: Tape
Notes:
This is a test

Image of Room:
Room Image
Location/Room: Livingroom
Temp: 75
Humidity: 20
Co2: 5
Media Used: Swab
Notes:
This is a test

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 86
Humidity: 70
Co2: 20
Media Used: Vacuum
Notes:
jit[ jhti jhti4h jhto4 jhoit4 ]jhtio4 jhit jhti4 [jhti[

Image of Room:
Room Image
Location/Room: Livingroom
Temp: 75
Humidity: 45
Co2: 12
Media Used: Air-O-Cel
Notes:
frn hgit ghti hgti [ghti[

Image of Room:
Room Image
Location/Room: Bedroom
Temp: 65
Humidity: 40
Co2: 5
Media Used: Bulk
Notes:
vr0[ hjti ]htjio ]-hjtyo- ]jhot ]jh6to4- ]

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 65
Humidity: 50
Co2: 15
Media Used: Air-O-Cel
Notes:
hkj htji4 0huyj5t94- yujh59 yuh59 uy9= uy95t uy95 =uy594=1

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 78
Humidity: 65
Co2: 5
Media Used: Swab
Notes:
jhoyi5 nuj69 u69- u69 uyj96-2 69- yuj96-2 ui69- 69- uy692-=

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 78
Humidity: 65
Co2: 15
Media Used: Swab
Notes:
gtr54 bjy5 6

Image of Room:
Location/Room: Bedroom
Temp: 65
Humidity: 40
Co2: 5
Media Used: Air-O-Cel
Notes:
bne htigh hj40 jhu0 yh5utj98 hjt=02

Image of Room:
Location/Room: Bathroom
Temp: 85
Humidity: 65
Co2: 25
Media Used: Swab
Notes:
htr uy ku .

Image of Room:
Room Image
Location/Room: LivingRoom
Temp: 78
Humidity: 50
Co2: 15
Media Used: Tape
Notes:
ghte hty j5y7 j763

Image of Room:
Room Image
Location/Room: Bathroom
Temp: 78
Humidity: 65
Co2: 15
Media Used: Air-O-Cel
Notes:
thtqht

Image of Room:
Location/Room: LivingRoom
Temp: 85
Humidity: 50
Co2: 25
Media Used:
Notes:
htyu uj5 75 ui573

Image of Room:
Room Image

#1337989

Also The above was the "Test Email"... when I tried it by entering a new job with rooms the rooms it worked. But then I only wanted one job to show on the "publish-my-things page so tried changing the view to limit to only 1. when i did that then when entering a new job with rooms No rooms were sent in the notification email.

Is there a way to do this: Only show the one job that the user just created on the publish my things page that will also include all the rooms associated with that job?

#1338485

1. You could play with the published state or a custom field that says "finalized".
This field would get updated on the last form for the new job marking it as finalized. The view would have an additional Query Filter searching only posts where that field is not checked. So always only one post (in theory, unless the user did not submit the last post, for example) can appear.

2. I had understood your notification already works. I think it's the Query Filter in the View that filters the posts (rooms). It says "Select items from the Rooms Repeatable Field Group group that is a related to the current post in the loop."

But this View is not added to a Loop, it's added in a Form's notification. When you display the form and click submit, the form sends the email.

What we should do here is to force that View to show only posts belonging to the one edited.
We might need to use a custom filter for this. I could make a few tests on your site directly to see what is possible, but can you confirm #3 below first?

3. Note that the Test Email will NOT respect any of this, expectedly, because it has no post to apply to.
This can and will only work on the real email for a real post.
So if #2 works when on the front end, then there is nothing we can change, because it's not expected to get the loop item in the backend (there is none) - so it returns all.

About the limit of the view to one item, you mention that then nothing more is sent in the forms' mail for the view.
I think that will be solved with my above suggestion to use the checkbox?

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.