Skip Navigation

[Resolved] Use Quform form to create custom post and set values for Types custom fields

This support ticket is created 5 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)

Author
Posts
#1330957

Hey Support,

While you go thru my site, I also need to map (I guess in functions.php) all custom Accommodation fields to a Quform form (yet to be built) for easy, paged form creation and the addition of multi-file uploading. The target users are middle-aged with limited tech experience so Quform's built in validation is a huge time-saver for me. I found this article which I have been trying to replicate with changes, but have had no luck with getting the structure right as my php is limited (hence Toolset).
https://wordpress.org/support/topic/use-form-field-inputs-to-inject-field-value-on-cmb2-metaboxes/

Unlike the article, I want to have the forms edit the Accommodation custom fields which make up the Accommodation establishments details so that the owners can add and/or edit their own Accommodation with the paged Quform ajax I have yet to create.

#1330963

I'm not very familiar with Quform, so I'll need to do some additional investigation. In general, I can give you this advice:
- Types fields are stored in the database with a prefix of "wpcf-". So if the slug of a textfield in wp-admin is "your-text-field", then the field in Quform should be given the key/slug "wpcf-your-text-field".
- Complex fields, like dates and checkboxes, may not be compatible because the data format for Types may not be the same as the data format for Quform. This should be evaluated on a case-by-case basis.
- Types fields that allow multiple values (repeating fields, not repeatable field groups) should be stored as separate postmeta values, not serialized data.
- Types post relationships are stored in proprietary format and probably will not be compatible with any post relationships established by Quform.

I'll do some additional investigation and let you know what I find out tomorrow.

#1331619

Okay I did some analysis on the Accommodation post type and I can see the following data in this post type:
- Accommodation Gallery Repeatable field group
--- Custom field Image
- Custom field Image x 3
- Custom field Multiline text
- Custom field Address
- Custom field Number
- Custom field URL
- Custom field Checkbox x 2
- Custom field Radio field x 2
- Custom taxonomy x 4
- Accommodation Gallery post relationship

So depending on which of these items you want to manage in a Quform Form, you'll have more or less of a challenge getting these mapped up. The simplest items will be:
- Image custom field
- Multiline text custom field
- Number custom field
- URL custom field
- Checkbox custom field
These simplest items are stored in the database in postmeta as basic text and numeric data. That should be fairly straightforward.

The more difficult items are:
- Address custom field
- Radio custom field
- Custom taxonomies
These more difficult items may require special treatment. You would have to manage the radio field options manually in Quforms, because there isn't a good way to get all the different radio options programmatically in Types. Types address fields are pre-validated by the Google Maps API. So if your Quform doesn't validate addresses, you cannot assume addresses will be valid. This could cause problems with distance-based searches and map markers. Finally custom taxonomies...I'm not sure if Quform has a way to integrate with custom taxonomies automatically. If not, then you'll have to manage the taxonomy terms manually or with a View of terms.

The most difficult items are:
Repeatable field groups (RFGs)
Post relationships
Toolset RFGs are basically posts in a one-to-many post relationship with the post that contains the RFG. So you'll be creating custom post RFGs with PHP code based on the form inputs, and linking those posts to the parent post with PHP code. Types post relationships are stored in a proprietary format, not in postmeta. We have documentation for connecting posts here: https://toolset.com/documentation/customizing-sites-using-php/post-relationships-api/#toolset_connect_posts

I can assist with any code that touches Toolset APIs, or if you need examples showing how to store or retrieve data for a Types field.

#1333835

Hey Christian,

Sorry, didn't mean to be without connectivity for so long. I have split the accommodation address to be entered separately with a Toolset form (for GMaps validation, as specified). And the post itself and all related RFG fields for the gallery (and relationships, with a default image) will be manually created by myself with a new user and the author relationship. All (except RFGs) to be edited thru the Quform. The radios are there for C-logic and I can rework my Toolset display conditionals to use the field values instead of the radios themselves. Please help mapping and saving the Quform field values to the Toolset values from Quform for the Accommodation wpcf values.

Gallery to be handled through the Edit Accommodation Gallery images View displayed on the My Accommodation page. Would like to include Quform link on the same page for Accommodation Owners (managed by Access) to edit Accommodation fields with the Quform we're mapping.

Thanx brother, Shaun

PS Content implementation happening tonight so segregated development of Quform and functions.php necessary. Happy to do a new Duplicator if necessary, but your admin login still works, so you can do it too...

#1333987

Hey Christian,
I dunno if this should be another split topic. I have a CPT for photographers and have thought to create a custom taxonomy to assign tags (hierarchical @ this point) to photos by certain photographers. How do I assign a photographer credit (taxonomy, set for now if best, or can be CFG select or whatever) per photo by author who uploads with photographer status (Access)? Each photo they upload to whatever post type will carry their photographer tag/category for reference on their individual photographer profile as well as where they upload it (ie. tour, activity, accommodation, post/page). Hopefully I've explained this correctly and you can help.
Shaun

New threads created by Christian Cox and linked to this one are listed below:

https://toolset.com/forums/topic/tag-photos-and-photographers-with-relevant-taxonomy-terms/

#1334467

Would like to include Quform link on the same page for Accommodation Owners (managed by Access) to edit Accommodation fields with the Quform we're mapping.
This is where I would start. You'll have to figure out how to create a link to a page that contains the edit post Quform, and sets the correct post to edit, based on the link. Once the link is working, we'll be able to test the form on the front-end of the site. This part is outside the scope of support I can offer here, as it is specific to Quform's software.

Please help mapping and saving the Quform field values to the Toolset values from Quform for the Accommodation wpcf values.
Sure, are you running into a specific problem you need assistance with, like a field that doesn't seem to be stored correctly or displayed correctly in the form? I can provide code examples showing how to get or set a value for Types custom fields. I'm not a Quform expert so I don't know what you need, specifically, or how to set up their forms to edit a post and its existing fields. Normally when you set up a form, you can add fields and specify their slugs so the form knows which fields to get or set in the database. Are you able to do this with Quform? Let's try a simple one like the Nightsbridge BBID, and try to get that implemented. The Types field slug is bbid, so the slug in the database will be wpcf-bbid.

We should address your photographer / taxonomy question in a separate thread please, so I have split that off into another topic.

#1336981

I have decided to stay with the Toolset edit forms, even for the RFGs. Too much time wasted on this frilly un-answer to an already manageable Types solution. Thank you for your effort.