Tell us what you are trying to do?
I have a property search page with a map, search fields (distance, state, city) and the property posts in the loop. The page is only available to logged in users who each have one "extended profile" custom post type containing info such as address, company, license #, etc. I would like to auto populate each first visit to the page (if they go to home page and back to property search page, that would count as a first visit again) a search field such as city (from property custom post type) by comparing to extended profile custom post type address/city.
Is there any documentation that you are following?
No. I searched existing support tickets.
Is there a similar example that we can see?
Not that I am aware of. The purpose is it defaults to show only properties on the map and in the loop that are in their default location (city - could also add zip code, etc, same concept). The user can choose to change the city and search elsewhere but again, it defaults "first" visit to the property view page.
What is the link to your site?
hidden link it's membership so would need to use user: testagent pass: testagent to see the property search page.
Hello, unfortunately there is no JavaScript API for front-end custom search filters, so the only way to programmatically select an option in a custom search field is to apply the corresponding URL parameter to incoming page links. For example, if you wanted to preselect the City option "Gilbert", you would have to format incoming links with that URL parameter already applied to the URL like so:
https://yoursite.net/search-properties/?wpv-wpcf-pcity=Gilbert
Without a true API for preselecting a search option, that's the only supported method of preselecting a custom search field.
Thanks. That's the route I was looking at but I would need to dynamically create the URL link so that "Gilbert" is pulled from a CPT for the currently logged in user. So the City custom field from the Extended Profile Custom post. Is there a way to do that, some sort of shortcode (that's what I've been searching for this morning).
Well you'd need a way to get the post associated with the currently logged-in User, ideally the post ID. If you can get that post ID, then you might be able to use the Types field shortcode system to give you access to a custom field from that post, using the syntax:
[types field="some-field-slug" item="1234"][/types]
You would replace some-field-slug with the slug of any custom field on the extended profile post, and replace 1234 with the ID of that post, or another shortcode that returns that post ID (for example, a View of posts filtered by post author, that outputs only the post ID with no other markup). If you need to nest shortcodes here, you must register custom shortcodes in Toolset > Settings > Front-end Content > Third-party shortcode arguments.
The number of supported nested shortcode attributes is limited, so depending on how you structure your code, you may need to accomplish some of this in a custom shortcode.
My issue is resolved now. Thank you!