Hello Martin, sorry, but it turns out that we cannot have any custom search in user views. Search is only supported for post views.
Check this screenshot hidden link
So, if you need to have a distance search to get the users or the ads based on an Address field, you need to rely on posts. The easiest way would be to add the addresses to the Ad posts. You can't use the authors' addresses in the distance filter.
I hope this answers your request. Let me know if you have further questions.
im a little lost here ? i shall TRY explain in full .
step 1)
once a user is signed up (standard theme sine up ) , they can then add an address via the edit profile page the address is a toolset address user field. Which uses
this field : hidden link
on this form:hidden link
the view is displayed on the profile page on a map by using php do shortcode in the themes template
step 2)
when ever a user posts an advert using the themes standard files and that advert is viewed it shows the users profile details on the right of the page ,including the map from step 1.
example:hidden link
step3)
each advert is in a category when a user now views category it has many filters all set up with the theme using fields and forms included , the only piece missing is distances which is vital , to sort this on the right in a widget is the map showing pins of the address from step 1
example: hidden link
so far PERFECT!
all that is required is too show a distance filter from the person viewing this page to the pins on the map . im not in a user view, im viewing the post of users who have a toolset addresses field assigned to themselves. the reason i have done it this way is eventually some users will have multiple address fields 1 for different sections on the websites.(all will be different toolset address fields)
1 at what stage is this breaking down ?
2 what do I do to rectify this ?
Hello Martin, it's fine, we'll find out a way to implement what do you need.
First of all, you need to understand that search, in general, is not possible for users or taxonomies. That means that we cannot have a distance search for users.
On the other hand, we can have a distance search for posts. I imagine two of the following ways:
- Add the address field to the Ads. This way we can search within the Ads by distance.
- Create a custom post type that will represent the users, and add the address field to it. This way we can search within these posts by distance. Please take a moment and read this article, it explains somehow this second suggestion https://toolset.com/documentation/legacy-features/views-plugin/how-to-create-custom-searches-and-relationships-for-users/
Regarding the first suggestion, we can find out a way to get the address from the user and save it on the ad when it is created. But we have to clarify this part before going down this road eventually some users will have multiple address fields 1 for different sections on the websites
Please think about it and let me know your thoughts or your questions.
main categories
gundogs for sale , ads will use the users address for sales
training , user will use a separate address as it wont be there home address
the only way i can think is to some how have a check box on the list advert form that they can choose any of their addresses in the profile ? the address would then be in the advert (post) so to speak .
for 2 catergories i need to show a big map with a users adress (pins) that can filter distance and other fields , is there a way to make this easier? or am i on the correct path ?
IF on my create advert form (themes form ) i have a toolset address field (not user custom field) where the user inputs the address whilst making the listing , then the address is tied to each advert (post type) as created, rather than the user i should be able to add distance filter and markers etc to any category no problem shouldn't I , as the theme will sort the categories so the toolset map filter will just use the posts loop ?
If you add an address field to the Ads, and then you add this field in the form for creating ads, you will easily get a distance filter in a map.
If you choose this road, I'll let you prepare the custom field, the form and update the ads with addresses. You can then create a new view that query ads from the category of the current archive. Then add a distance filter to it. On the distance filter, you can activate the "Use my location" button, to let the user filter ads by distance from his current location.
I'll be glad to help if you encounter any issues.
brilliant thanks jamal, so just to clarify a few issues before i start this journey.
1) would i need to set up a map and view for each category ? ( i hope not )
2) would i be abe to add filters to the map for any custom fields or just toolsets ? (not user fields)
hi jamal i found this in my thee files for creating my listings.
// allows to hook after ad details
cp_action_after_ad_details( $form_fields, $post, $location );
am i correct in thinking
i need to create a field for the address in toolset then create a view
finally get a function wrote containing the view , so its hooked in the correct place when the advert is created.
thanks
add_action( 'cp_action_after_ad_details', 'my_details', 3);
function my_details( $form_fields, $post, $location ){
var_dump($form_fields);
$form_field[] = 'how do i get my toolest field here';
return;
}
so my bit im unsure of is "how do i get my toolest field here"
to display the map i understand i need a view , but to add the field to my advert do i need a view or a field and how do i insert it into my function above? thnaks (almost there )
My apologies for the late reply, but I do not work on Wednesdays and Thursdays.
I installed and activated the "Download Plugins and Themes from Dashboard" plugin to download the theme's files and search for this hook and how it is being used.
I was not able to understand where this hook is used(cp_action_after_ad_details). Based on the file name "custom-forms.php", I would assume that it is used in a Form that allows creating Ads. If that's the case, it won't be simple to add a Toolset custom field into it.
If you want to allow users to choose a location using Toolset Maps, you need to do it through a Toolset form, not within the theme's form. Maybe the theme's form can redirect to another page that holds the Toolset form, and there the user can enter the location.
Regarding your first questions: 1) would i need to set up a map and view for each category ? ( i hope not )
Only one view (with a map) can be used for every category. The trick is to use query filters on the view and choose the category of the current archive page.
2) would i be abe to add filters to the map for any custom fields or just toolsets ? (not user fields)
The distance filter can be implemented only for Toolset Maps Address field. But you can filter other Non-Toolset fields (numbers, texts, etc.)
To better assist you further, I need to know more details about the Ad creation process. How Ads are being created? From the frontend, I assume, if yes, where? No Toolset Post Forms are created, so I assume, that the theme or a theme's plugin offers a form to create them, where can I see this form?
This ticket is now closed. If you're a Toolset client and need related help, please open a new support ticket.