Skip Navigation

[Resolved] Storing Address Components in Separate Custom Fields

This support ticket is created 3 years, 4 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
- 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 7:00 – 14:00 -
- 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 15:00 – 16:00 -

Supporter timezone: Europe/London (GMT+00:00)

This topic contains 4 replies, has 2 voices.

Last updated by Dallin Chase 3 years, 4 months ago.

Assisted by: Nigel.

Author
Posts
#2097321

Hey guys,

I'm trying to use Javascript to take the separate address components from the Google Address field and store them as custom fields. For example I would be able to get the City, Postal Code, State, Country, etc.

I found this thread (https://toolset.com/forums/topic/separating-content-from-the-address-field/) and I've used the code which is working on the front end but it doesn't seem to be submitted on the backend.

Here is a video: hidden link

Thank you in advance.

#2097619

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

Hi Dallin

I watched your video, and see that you are doing this with a front-end form (the original thread was aimed at back-end post edit screens), and you seem to be most of the way there, inasmuch as you have populated fields in that front-end form with details from the geocoding result.

If those values don't seem to have been saved (when you check the back end) after submitting the form, it sounds like you maybe added generic fields to your front-end form rather than the custom fields themselves (you must have registered some custom fields if I can see them in the back end in the video). In that case, the generic fields would be discarded after submitting the form.

You could add some code using the cred_save_data hook (https://toolset.com/documentation/programmer-reference/cred-api/#cred_save_data) to map those generic fields onto the actual custom fields, but the simplest way would be to include the custom fields directly in the form.

Does that sound like it is the problem?

#2098311

Okay, I will try with the default fields and get back to you. Thanks.

#2098943

Nigel
Supporter

Languages: English (English ) Spanish (Español )

Timezone: Europe/London (GMT+00:00)

OK, let me know how you get on.

#2099379

This worked perfectly when using the right fields. Thank you.