Skip Navigation

[Resolved] Form plugin recommendations

This support ticket is created 3 years, 11 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
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Author
Posts
#1615597

Can anybody recommend a contact form plugin that is compatible with (and gives access to) to Toolset fields?

I know that Elementor and Toolset and well-integrated and you can use Toolset data in the forms. I’m using Astra on a couple of sites and I’d like a plugin for a couple of different forms (contact, subscription, requests). I’ve tried a few of the free ones so far (Ninja, Caldera, WPForms, etc) but I find the Toolset/custom field integration is... lacking.

#1615807

Hi, Toolset Types isn't directly integrated with any 3rd-party form plugins so I don't have a great recommendation for you here. The only form plugin that will completely support all of Types fields and data formats is Toolset Forms. Other form builder plugins will have varying degrees of capability and integration. Is there something specific you want to accomplish that cannot be accomplished with Toolset Forms? A basic contact form can be created with Toolset Forms in a matter of seconds once you create the custom post type and add fields in Types.

To some degree, your success here will also depends on what you mean by integration and giving access to fields. What exactly would you like to accomplish? For example, how would a request form integrate with Types fields, exactly? What about a subscription form?

The main thing to be aware of with Types field integration in 3rd-party systems is that Types fields use a slug prefix of "wpcf-" in the WP postmeta database table. So if you create a field in Types with the slug my-field in wp-admin, then you'll need to set the field slug in a corresponding 3rd-party form to be wpcf-my-field. Any system that implements custom fields using standard WordPress postmeta will therefore have some degree of integration by default, usually enough for simple text, email, url, and numeric fields. Other more complex fields like dates, checkboxes, select or radio fields, wysiwyg fields, or any type of repeating field structure may or may not be compatible depending on the data format and syntax used by the 3rd-party plugin.

#1618321

Hi Christian.
Thanks for your response. I thought that would be the case. Strangely enough, I thought about Toolset Forms after my original post. I’m still working through things. If I explain the situation that I’m facing, perhaps you would be kind enough to offer some guidance?

I have a client who wants to make a large number of files available online to its customers. There are different versions of these files. Some are documents. Some are video files. My client does not want a full-on membership website. My client just wants to know which customers have downloaded which documents and then, in the future, it can perhaps send the information directly to them. A simple email address is sufficient.

I’ve created a CPT called “Downloads”. The title field is the name of the file and version. I’ve created custom fields for additional information such as publication date, file size, etc. I’ve also created a file upload field for the file. It will all be managed through the backend.

I’m using Astra and Blocks and have designed the appearance of these posts/the loop. The idea is that there would be a box underneath into which a customer enters their email address for a new CPT called “Requests” and it a) records which file they’ve downloaded and b) redirects the customer to the file.

My initial thoughts were as follows:
1. Create a CPT called “Requests”. This contains fields for name and email address.
2. Create a form which also includes a hidden field that records the post title (which is the name of the file).
3. Redirect the customer to the file on submission.

I’m sure that I don’t need to tell you the problems with this scenario. The requests form is fine. The name and email addresses being logged properly. The hidden field with the “Download” post title however doesn’t register within the Requests because… well, I don’t know. I’ve created a one-to-many relationship with the Downloads being ‘one’ and the Requests being ‘many’. The only problem is that it produces a drop down box that you select the download from. I don’t want this. I want it automatically selected according to the post title.

Beyond that, there’s the redirect issue. I’m not sure how to redirect the user to the URL of the file and not the post itself. Any help on that would be amazing!

#1623099

Shane
Supporter

Languages: English (English )

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

Hi Simon,

Reading through the threads its seems you really just have 2 issues to be solved by toolset .

1. This is to get the parent information automatically filled in. In order to achieve this you will need to follow the instructions in the link below.
https://toolset.com/documentation/post-relationships/selecting-parent-posts-using-forms-create-child-items/#creating-forms-when-a-parent-post-is-preselected

2. I'm assuming the Downloads will be dynamic based on the Parent Post correct? This section would require some custom code to add to the Forms redirect in order to tell the user which page to go to.

This can be done based on the parent ID so if you create a post that is related to the Downloads CPT lets say in a 1-1 relationship then you should be able to pull the relationship information. How familiar are you with PHP as this will require some PHP knowledge in order to achieve.

Please let me know.
Thanks,
Shane

#1623117

Hi Shane,

Thanks for the reply. I've already started looking through the link you posted - I stumbled across it not half an hour ago. Looks fairly self-explanatory but there no doubt I'll trip up somewhere.

Number 2 is definitely the key. In answer to your question, yes, the file will be dynamic. The link is stored in a field called [wpcf-file-pack] in a CPT called (rather originally) "Downloads". I'm ok with PHP. I'm not amazing but I generally know what to look for and if not... well, there's always a support forum somewhere!

Any guidance always appreciated.

Best wishes
Si

#1623263

Shane
Supporter

Languages: English (English )

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

Hi Simon,

Great so the idea of resolving it would go like this.

The easiest way to resolve this would be to create a 1-1 relationship with a CPT that would hold the download file. When your user submits the request we would want to dive through the relationship to pull related data for the parent and redirect them to that page.

Given that the tutorial to dynamically assign the parent to the child post form will pass the parent ID in the URL we can actually retrieve it when using the redirect hook, see below.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_success_redirect

Example to get the Parent ID in the hook would be.


add_filter('cred_success_redirect', 'custom_redirect',10,3);
function custom_redirect($url, $post_id, $form_data)
{
    if ($form_data['id']==12 && isset($_GET['url_param'])){

return $new_url;
   }
    return $url;
}
 

The $_GET would be able to get the URL parameter's value which would be the parent ID.

Given that you have the Parent ID you can use this function below to get the child
https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_get_related_post

The function will return a Post ID.

Finally when you have the child post ID you can use this function here get the URL.
https://developer.wordpress.org/reference/functions/get_permalink/

Within the if statement you can just return the url for a successful redirect.

Please let me know if this helps.

Thanks,
Shane

#1624941

Hi Shane.

It worked! I managed to find some time to test it out this evening. Thanks ever so much.

In the process of doing all of this, I have encountered a minor issue. A little advice would be useful...

I have a template for my Downloads with info pulled from the CPT and its fields. The plan was for the Requests form to appear on the template further down the page. Using the method above (child link) however, it asks for the location of the form. I hadn’t designed a page specifically for the form. I’d designed a form but it was just going to be added to the Downloads template. I’ve had to create a page with the form on it to which takes the user away from the Download page. Is there a way around this?

I’m not thinking entirely clearly about it at the moment but it strikes me as being similar to the Toolset login page. The button and form appears on the same page as the message telling you to login to access everything.

Best wishes
Si

#1626121

Shane
Supporter

Languages: English (English )

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

Hi Simon,

For clarity you want the Child form on the page itself rather than having the form being on a separate page?

Please let me know.

Thanks,
Shane

#1626127

Hi Shane,

That's right. The Child form on the page itself.

As I said, I wasn't thinking entirely clearly after yesterday after a particularly busy day...!

Best wishes
Si

#1626161

Shane
Supporter

Languages: English (English )

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

Screenshot 2020-05-15 at 11.11.24 AM.png

Hi Simon,

You can add the child form itself to the page however you will need to adjust your the hook I provided as well as the relationship field on the form.

Given that the parent is no longer being passed as a URL parameter but is now on the field itself.

First you will need to set the default value for the parent field on your child form to [wpv-post-id] see screenshot

Then adjust the Hook like this.

 if ($form_data['id']==12 && isset($_POST['@post-car-2.parent'])){
 
return $new_url;
   }
    return $url;

Where @post-car-2.parent is my relationship slug. In your case it would be "@{relationship-slug}.parent" replacing relationship-slug with the actual slug of the relationship.

Please let me know if this helps.
Thanks,
Shane

#1629081

Hi Shane

Apologies for the tardiness in my reply. It's been a long few days finishing another project.
That solution works perfectly!

Thank a lot for your help on this one. It's greatly appreciated.
Si

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