Skip Navigation

[Closed] Pass Reference Data of One CPT to a Form that Creates another CPT

This support ticket is created 2 years, 9 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
8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 8:00 – 12:00 - -
13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 13:00 – 17:00 - -

Supporter timezone: America/New_York (GMT-04:00)

Author
Posts
#2122193

We are building a website were user can book appointments with the Therapists. We created two custom post types, Providers and Appointments and set a one to many relationship between them. We want to have a book an appointment button on the content template of providers ( therapist ) which opens a form for the appointment booking (made with toolset post form). That appointment form should belong to that provider only. How can we pass the that provider data to the appointment form page to create a new appointment ? How this can be implemented?

#2122497

Hello, it depends on the specific information you want to pass into the Appointment Form. For example, if you want to preselect the appropriate Provider in the post relationship field, you can use a Create Child Post Link in the Provider template as described in our Child Post Form documentation:
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/
When the User clicks a Create Child Post Link in the Provider template, they will be redirected to the Appointment Form with a special parameter applied to the URL, something like ?providerid=123, where 123 is the ID of the Provider post. This will tell the Appointment Form which Provider should be pre-selected in the post relationship field. You can use CSS to hide the post relationship selection field in this scenario and the User will not be able to see the post relationship field or select a different Provider. I can help with that if you are not comfortable writing CSS, I would need to see the Form on your site to provide an example snippet.

If you want to pass other information into the Appointment Form, I need to know more about the types of information you want to pass, and where you want to apply those pieces of information in the Form. For example, if there is a custom field in the Appointment Form and you want to predefine that custom field automatically based on a different custom field in the Provider post. In this scenario you will use a combination of shortcodes and URL parameters to pass the information from Provider to Appointment Form. I would need to know the field type and slug for each of the fields involved to provide some examples.

Let me know your thoughts and I can offer more direct guidance if necessary.

The topic ‘[Closed] Pass Reference Data of One CPT to a Form that Creates another CPT’ is closed to new replies.