Skip Navigation

[Closed] Allow user to edit address field in custom post type

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: Asia/Karachi (GMT+05:00)

This topic contains 3 replies, has 3 voices.

Last updated by Waqar 1 year, 8 months ago.

Assisted by: Waqar.

Author
Posts
#2665791

Ian

Tell us what you are trying to do?

I'm currently developing a website which is on its staging site.
Each user can have a directory listing. This directory listing is a custom post type "directory-member" for which they are the author. Each user can only have one directory listing. In this custom post type there are a number of custom fields including:
Address (which uses the "address" field type)
Address First Line (uses single line field type)
Address Second Line (uses single line field type)
Address Town/City (uses single line field type)
Address County/State (uses single line field type)
Address Postal Code/ZIP (uses single line field type)
Address Country (uses single line field type)

I want to give the logged in user the ability to set or change their location in the Address field so it can show on the members' map.
Ideally it would give the option to take the information from the other address fields (which you can see above), or be able to just select it on a map. Or choose from their current location. How do I do this? Do I use Toolset Forms? I'm using Gravity Forms for other areas of the website but happy to use Toolset Forms if I need to. I just don't know how to use it to allow a logged in user to post a new location to the address field.

Is there any documentation that you are following?
I can't find any specific documentation on how to this.

Is there a similar example that we can see?
No

What is the link to your site?
hidden link

#2665833

Nigel
Supporter

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

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

Hi there

The address field is a special field that doesn't just store a text version of the address. It uses the Google Maps API to offer an autocomplete of a "correctly" formatted version of the address which also returns the latitude and longitude coordinates for the location.

It behaves the same way whether entering the data in the back end or in a front-end Toolset Form.

There isn't really any way to reproduce that starting from a series of address fields.

Something more like the opposite would be true.

You could have a form that includes the Maps address field, and when a user enters an address there you could automatically populate other fields (e.g. city, post code etc.) based on the data returned by the Google API.

Your clients could edit these fields if they needed tweaking, but the canonical version of the address for the purposes of displaying a marker on a map, for example, would be that stored in the Maps address field, coming from the value returned by the Google API.

If that sounds like a viable option then I suggest you check this page about how to create a Toolset Form: https://toolset.com/course-lesson/front-end-forms-for-adding-content/

The when it comes to using the data returned by the Google API to populate other address-related fields, see this old thread for a similar example: https://toolset.com/forums/topic/separating-content-from-the-address-field/

#2667391

Ian

Thanks, sorry for the delay... the email ended up in my spam for some reason.

What I really need is a very simple form which allows people to set / edit the address field in the custom post. Ideally they should be able to click the map to adjust where their location is.

Sorry if I am being stupid here, but how do I create such a form with a map which will update the address field in their post on the front end?

#2667511

Hi,

Thanks for writing back.

What you're trying to achieve is supported by Toolset Forms and should be very straightforward.

If you don't already have one, please add one 'Address' type custom field, through Toolset Types, with your directory custom post type.
( ref: https://toolset.com/course-lesson/front-end-forms-for-adding-content/ )

I understand that the directory post from user is created through a Gravity Forms. To include the management of this new address type field, you can create one form to edit the director post type, through Toolset Forms.

This form will have the new address type field and will be placed on the single directory post page, so that users can edit the stored address, right from the same page.

In case, you face any challenge in making this set up work, you're welcome to share temporary admin login details, along with the link to the page with this form.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

regards,
Waqar

The topic ‘[Closed] Allow user to edit address field in custom post type’ is closed to new replies.