Tell us what you are trying to do?
I'm developing a used machine listings website and want to include a "Request more info" Form to be displayed in each machine Content Template page so that users can request more info about the machine they're seeing. I believe the best way is to create a CPT for contacts along with the customs fields I need and then create a form to include in the Content Template, right? The challenge is that I want to automatically include in this form the Listing ID of the machine that the user is interested in, so that when I receive the email request for more info I know what's the machine the user is refering to. The machine listing ID is in another CPT called "Equipments". Can I do this with Toolset?
Please be aware that I have no coding experience at all.
Is there any documentation that you are following?
Toolset Forms
Is there a similar example that we can see? hidden link
What is the link to your site?
(it's still under development) hidden link
(It currently includes a Kadence Form that I was experimenting with but I guess it's better to do it with Toolset)
The challenge is that I want to automatically include in this form the Listing ID of the machine that the user is interested in, so that when I receive the email request for more info I know what's the machine the user is refering to. The machine listing ID is in another CPT called "Equipments". Can I do this with Toolset?
Hi, it sounds like you have a CPT "Equipments" that includes the Listing ID information you need, and you want to include that Listing ID information in a Form that creates "Contact" CPT posts. Assuming the Form to create Contact posts is displayed in the template for Equipment posts, and Listing ID is a custom field in Equipment posts, you have access to that custom field with a shortcode like this somewhere in your Form:
That would give you the Listing ID from the current Equipment post. Let's say your Contact post type has its own custom field to store the ID of the item the site visitor is interested in. In the Form that creates Contact posts, you could automatically set that custom field value by adding the shortcode I included above as the field's default value. See the screenshot here for a similar example of the default option set by a shortcode.
So that would store the listing ID from the current Equipment post in the new Contact post created by Forms. Would that give you the information you need, or am I misunderstanding the setup and requirement here?
Hello, many thanks. This is exactly want I want and your solution works perfectly.
If I want to use the Equipment's "Post ID" (generated automatically by WordPress), instead of the Equipment's "Listing ID" (custom field manually created by me ) how should I proceed? I tried to change the slug in your shortcode to "post-id" but it didn't work. Thank you in advance!
Christian is currently on vacation at the moment, however if I understand the issue correctly, you want to use the ID of post of the Current page rather than the custom field value that you've specified correct?