Skip Navigation

[Resolved] Connecting a custom post type to a contact form

This support ticket is created 4 years, 3 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)

Tagged: 

This topic contains 15 replies, has 3 voices.

Last updated by chrisF-16 4 years, 2 months ago.

Assisted by: Christian Cox.

Author
Posts
#1843513

Tell us what you are trying to do? We have a custom post type for doctors accepting patients on our site. I'd like to include a function into a contact form where you can choose one of the doctors who has their accepting status set to "yes". Is it possible to do this with Toolset forms, or can you recommend a contact form plugin that will integrate with Toolset?

Is there any documentation that you are following?

Is there a similar example that we can see? A working example is on our current live site, scroll to the bottom for the contact form. The function we're looking to replicate is Select a Doctor, the current site uses contact form 7: hidden link
We've made changes in our dev site to how the accepting status works within Toolset, so the current setup with contact form 7 no longer works.

What is the link to your site? hidden link

#1843619

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

Thank you for getting in touch. In order to make this work you will first need a couple things.

1. A new post type "Inquiry" or anything that can identify the messages to the doctors.
2. The doctor's email on their profile page.
3. A post relationship between inquiry and doctor.

How we will use Forms to achieve this is by setting up a post relationship and the inquiry being a child post of the doctor. So when the user submits the inquiry it will be link to a particular doctor and both doctor and patient can get an email about this inquiry.

Please let me know what you think of this idea.

Thanks,
Shane

#1846695

Hi Shane,

Thanks for the response and the suggestions!

We're currently talking to the client to confirm how they would prefer the contact process to take place, I'll get back to you within the next couple days.

#1847591

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

Thank you for the update.

Looking forward to your client's decision soon.

Thanks,
Shane

#1848989

Hi Shane,

The client would like to keep the contact process the same as it is on their current website:

- The contact form will send to a single admin email address
- No copy of the email is necessary for the doctors
- Need to have the dropdown in the form showing a list of all doctors who have an accepting status ID of "Yes"

Thanks again for your help, and looking forward to your feedback!

#1849169

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

If the client choose to do it without Toolset Forms then they you will need a plugin that can dynamically get the email from the custom field.

Frankly i'm not aware of a plugin that can dynamically get the email from the post. The best option right now is to use our Toolset forms given that it can be used in this fashion to dynamically get the Doctor's email.

Also in Views you can filter by the doctor's status ID.

Thanks,
Shane

#1849685

Thanks Shane!

I think there's been some miscommunication, as we don't need the Doctor's email at all.

We only need to know which Doctors are accepting patients (which we have setup with our Views), and be able to create a dropdown list of those Doctors within our contact form. The form itself will always be sent to a single admin email address.

If you take a look at how this works on the current website, it might help explain what we're trying to do. We'd like the new contact form to function exactly like the current one does, the problem is with the recent changes we've made in our Toolset views, etc., I'm not sure how to achieve this:

hidden link

Please let me know if you have any questions, and thanks again for your help!

#1850029

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

We only need to know which Doctors are accepting patients (which we have setup with our Views), and be able to create a dropdown list of those Doctors within our contact form. The form itself will always be sent to a single admin email address.

I see what you mean now. This is going to be a bit tricky as it is something advanced in views.

The first thing you will need to do is to go to Views -> Add new and create a view. Select your Doctor CPT and then add the query filter to the view to select only the ones with "Yes".

In your view loop output section replace it with.

<wpv-loop>
			[wpv-item index=other]
				{"value": "[wpv-post-title]", "label": "[wpv-post-title]"},
			[wpv-item index=last]
				{"value": "[wpv-post-title]", "label": "[wpv-post-title]"}
		</wpv-loop>

Then ensure on the view you've selected "Disable the wrapping DIV around the View".

In your Forms you will create a generic field for this, Ideally a select field and then add your view to the select field.

This will dynamically generate a list for you to select in the form itself.

Please let me know if this is more something you're working towards.

Thanks,
Shane

#1855665

Hi Shane,

I've created the View as per your instructions, but I'm unclear on how to build the form as I have no experience with Toolset Forms. Would this be a Relationship Form that is needed in this case?

If I provide you with admin access, is this something you would be able to assist me with?

Thanks!

#1855689

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

Based on your website here
hidden link

You have a patient registration form. In terms of Toolset you will need a Patient CPT and relate it to doctors. The Patient form will essentially allow the patient to get registered to a doctor.

I believe I see this a bit more clearly now. So here is what i'm thinking.

1. Create a CPT called Patient.
2. Create a relationship between Patient and Doctors, Ideally you will check what type of relationship is needed.
3. Create a Patient form and add it to the Doctors page, this should automatically select the current doctor being viewed and all the user needs to do is to add their respective information.

Please let me know if this sounds a bit more like your workflow. You can already use the view to filter for the doctors who are taking patients.

Thanks,
Shane

#1859415

Thanks Shane!

I think only having the contact form on the Doctor's page, and not on the main Find a Doctor page could work, as you're suggesting.

Patients could still use the Doctor Finder to see which doctors are accepting patients, click on that doctor, then use the contact form to book an appointment.

I was able to create the CPT for Patient, but I'm not sure how to complete steps 2 and 3 from your instructions.

If I provide login access, are you able to login and set up the form and relationship? Or are there detailed instructions I can follow on how to do that?

Thanks again for the help!

#1859463

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Chris,

I could log in a set it up for you but here below we have some documentation that I can point you to .

For the post relationship creation you can use this tutorial below.
https://toolset.com/course-lesson/how-to-set-up-post-relationships-in-wordpress/

Then you can use this below to create the form that is required.
https://toolset.com/course-lesson/selecting-parent-posts-when-using-forms-to-create-child-items/#creating-forms-when-a-parent-post-is-preselected

Thanks,
Shane

#1862779

Thanks again Shane,

I was able to create the Patients > Doctors relationship using the instructions you provided, but I'm still lost when it comes to the actual form creation.

I've created a login for you, hoping you can help me finish off this final step - is it safe to post that info in this chat, or do you need to set the chat to private first?

#1862953

Hi, Shane is on vacation this week so I'm checking in on his tickets. I have activated private reply fields here so you can share login credentials securely. Can you tell me where you're stuck creating the Form? Is the lesson link misleading or confusing in some specific way?

#1866737

We would like the form to function as a standard contact form, sending the request for an appointment to a single admin email address. In the instructions that were provided, I'm not seeing how to do this? The instructions describe how to use Forms to create post content, or add content to an existing post.
Correct, Toolset Forms is a plugin that is intended to be used to generate or edit some specific content, either a post or a User. It is possible to generate automatic email notifications when a post is created or edited with Forms, but there is no Form type that simply sends email without adding or editing some content. So in your case, you can set up a Form that generates new posts in some custom post type, and trigger an automatic email notification during that process. That also gives you the opportunity to keep a history of contact requests outside of email. If you want, you could configure the Form to generate new posts in Draft status so they don't appear on the front-end of the site, and clear them out periodically if you don't want them hanging around in wp-admin.
Notification documentation is available here:
https://toolset.com/course-lesson/send-notifications-when-someone-submits-the-form/