Skip Navigation

[Resolved] Signup form that allows a user to list a motorhome + API

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

Supporter timezone: Africa/Casablanca (GMT+01:00)

Author
Posts
#1598729

I'm trying to build a form that allows a user to signup to the platform to list their motorhome for sale.

My ideal scenario is this:

Step 1: The customer enters the Registration plate of their vehicle. In the backend, I have a DVLA API search plugin which pulls back information about the vehicle

Step 2: The API results sit in the form allowing the user to continue (an example of this is hidden link)

Step 3: The user selects an advertising package that determines how long the advert is up for/how many images they can store etc

Step 4: The user continues filling out various details, specification, upload images etc

Step 5: The user then submits the listing for payment > the form captures payment and if successful displays the listing. If unsuccessful it holds the details and shows the user the issue. The form should still register the user and save the information.

I've tried to follow various different guides on the Toolset site to achieve this but keep hitting a brickwall at Step 1 😉

In addition, the site needs to allow someone to login and amend their details if required as well as fully delete (as per GDPR).

I'd appreciate any help!

#1599691

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Hello and thank you for contacting the Toolset support.

Currently, in Toolset, a post form is used to create or edit only one post. A user form is used to create or edit only one user. We'll need two steps, one for registering user, then creating a post by that user.
1. Registration Form with a redirect to an "Add your item" page.
2. The "Add your item" includes a post form to create the item.

To handle this in one form, you will need custom code. Use generic fields in the user registration form to collect the information about the post, and then, programmatically create the item(moto) after user registration.
- Insert generic fields to capture Motor fields: https://toolset.com/documentation/user-guides/inserting-generic-fields-into-forms/
- Add some custom code with the Forms API cred_save_data to collect the information from the generic fields, and store that information by programmatically creating a Motor post. You can set the new User as the post author to connect the User and the new Party.
https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data
https://developer.wordpress.org/reference/functions/wp_insert_post/

You may find this ticket useful: https://toolset.com/forums/topic/auto-create-custom-post-after-new-user-submission/

Now depending on how you will collect the moto API, you may want to create a post first, then assign it to the user after registration, by keeping an ID in a session object.

You can have another post form for edit where you enter more details.
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/

At this point, the motor may be just a draft or pending review, once you collect the payment you can change its status to publish. Check this article https://toolset.com/documentation/user-guides/front-end-forms/using-cred-commerce-to-add-payments-to-forms/

I hope this helps. Let me know if you have any questions

#1600477

Hi Jamal, thanks for that. I'll have a further look using the articles you link to. Appreciate the pointers.

#1600495

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

Awesome 🙂 I'll be happy to help.

In the meantime, I'll kindly ask you to mark this ticket as resolved and open a new ticket for any other question.

All the best,
Jamal

#1600503

A couple of other quick q's,

In the Add New Fields dialog box, there a number of things to select but nothing for Price - ie, a floating point number, the closest being Number.

However, I can foresee the following example inputs:

£35,000
35,000
35000
£35000
£35000.99
35000.99

Whilst the £ will be rejected as it's not a price the other values are still valid.

As the output needs to render like this: £xx,xxx (no decimal points), what is the best way to ensure the input matches this?

A default value or placeholder demonstration value isn't strong enough to remove the potential issue.

Also, is there a way of validating input in real-time rather than waiting for a submission to be made?

Finally, how to remove or edit the --not set-- of a select field? I'd rather have 'Please Select'.

Thanks

#1600853

Jamal
Supporter

Languages: English (English ) French (Français )

Timezone: Africa/Casablanca (GMT+01:00)

I believe the price field should be number, and you can use one of the techniques described in the following links:
- https://toolset.com/forums/topic/transforming-content-in-number-field-as-price/
- https://toolset.com/forums/topic/types-number-field-set-number-of-decimal-places-to-2-for-product-price-in-gbp/
But for a realtime validation of the price on the frontend, you will need to implement a custom Javascript code or maybe use a validation library in the Javascript section of your form.

To customize "--not set--", you will have to switch to expert mode for form creation and use the select_text attribute like this:

[cred_field field='motor-status' force_type='field' class='form-control' output='bootstrap' select_text="Please Select"]

Read more about the shortcode here https://toolset.com/documentation/user-guides/front-end-forms/cred-shortcodes/#cred_field

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