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?
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.