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.
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.
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?
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.