Skip Navigation

[Escalated to 2nd Tier] limit a search

This support ticket is created 3 years, 7 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.

No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Tagged: 

This topic contains 13 replies, has 2 voices.

Last updated by Shane 3 years, 7 months ago.

Assisted by: Shane.

Author
Posts
#2026249

Can you tell us step-by-step how we can limit a search for specific users on for example hidden link?
For example:
User x can only search for specific cities.

#2026489

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

Thank you for getting in touch. It is possible to do this if you are doing this for a specific user or User role and if we are working with a Taxonomy filter for the city.

If you provide a bit more information on this I will see if it is in the realm of possibilities of assistance we can provide given the hooks we have available to us.

What I want to know is if City is a Taxonomy or is it a custom field secondly will you being doing this for 1 specific user or group of users or for a specific user role.

Looking forward to hearing from you.
Thanks,
Shane

#2026493

Shane,

Here are my answers:

>> We are using the following custom fields (not taxonomies):

A: Search within km from address.
B: Provinces
C: Cities

>> We want to limit search for specific users.

#2026663

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

Thank you in this case given that Cities aren't taxonomies i'm assuming that they Cities is a Post Relationship.

In such a case we are not able to modify the filter when it is being displayed. Limiting the items per user wont be possible in this case.

It would be possible if the field was a taxonomy or a custom field, as we can use the hook below to modify the taxonomy fields and fo custom fields we can just create a duplicate filter that is added in a conditional for the user.
https://toolset.com/documentation/programmer-reference/views-filters/#wpv_filter_taxonomy_frontend_search_available_terms

Essentially if this is to be done it would require custom code that would be out of the scope of our support forum.

Thanks,
Shane

#2026677

What needs to be done to change the custom fields / post relationships into taxonomies and what hook exactly schould be added where to show the search within km from address, provinces and cities only to specific users?

Step-by-step please - we are NO coders!

#2026717

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

Changing the post relationship information will mean a redo of the setup of your site, so if your site is built to run based on the post relationship then it will affect the site's function if you were to change it to custom fields.

Now with custom fields you will also lose the dependency filters, this means that you won't be able to have the province filter disabled until a city is chosen.

If you choose to do this then you will need to recreate all the cities and province as taxonomies which will allow us to use the hook to modify the values.

There are a few things that we would need consider when changing the items in the filter. What I mean is that if we have 50 different users then its not logically feasible to write 50 different conditionals to ensure that each user is able to select the cities specific them.

Now if the user has a checkbox that lets say City and they pick a city from that, then this will group the users based on their locations. There are issues that can arise with this where if you have 200 different cities then logically it won't be feasible to write a conditional for 200 different cities. Before any assistance can be given we would need to understand how will those users or group of users will be selected and what cities will show for that set of users vs another set.

Thinking about this it would definitely require custom coding which would fall outside of our support scope. I see that you've mentioned here "what hook exactly schould be added where to show the search within km from address," Have you already added the distance filter to the view ? As this will allow you to narrow down user's location and allow the appropriate posts to be shown within their region.

If the distance filter is already added then we can add some conditional code to the relationship filter that will only allow it to show after the user has performed a distance search first. This will automatically set the filter to only show the cities within the area that they are located. This would be the simplest way to do this without having to change the functional structure of your site. Here is an example of what i'm referring to below.

hidden link

This has a distance filter that the user can filter the posts based on their location. Please let me know what you think of my suggestion.

Thanks,
Shane

#2027205

The posts to show should not be based on a specific user location.
The user can be located in Antwerp but we only wish him to show locations in Leuven for example.
I don't see how it can be that difficult to limit searches for specific users.

#2027723

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

I had our Team lead look at this to see if we can possibly provide a solution for you. However in order to know how what can be done we must first understand how will the users be selected to hide the various other dropdowns.

Will the user's profile itself have their locations on it ? what attribute of the user will be used to determine what they see.

Once we understand this we will know whether or not something can be done.

Thanks,
Shane

#2028195

Based on the usecase you can yourself suggest a valuable and workable solution following the current site setup.

#2028941

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

This will take some more time as i'm discussing what approach can be taken to handle this issue.

I cannot guarantee that we will be able to provide a solution for you given that this is not natively possible. We are discussing the proposition of having the user's create profiles and link those profiles to cities in a Many to Many relationship.

Will provide you with an update as soon as I have one.

Thanks,
Shane

#2030027

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

I've tried to have a look at the site but it would appear that i'm not able to see it.

Can you provide admin access to the site so that I can have a look to see how your relationships are setup ?

I've enabled the private fields for your next response.

Thanks,
Shane

#2030029

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Private fields

#2033215

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

Just an update here, I'm still in dialogue with our Team lead about this one. Right now i'm waiting on a final answer on whether this is possible to do or now.

Currently it doesn't look possible to achieve based on how the post relationship is designed, we aren't able to hook into the functions for this at any point, however we are still looking and i'm awaiting a final response from him.

Will provide an update accordingly.

Thanks,
Shane

#2034501

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Matthias,

I've got some feedback from our Team leader for you.

"We spent quite some time digging into the plugin source code to see if either of the two routes I see to implementing this were possible, but have concluded it is not.

I discussed with the lead developer who confirmed the findings—a solution cannot be implemented even using custom code without making changes to the plugin code itself—and they recommended to file an internal ticket about making such changes so that it would then be possible to produce a solution.

This has been done. We have a mini-development cycle underway currently, but the next main development cycle is about improving search filters amongst other things, and this will be undertaken then."

Given that such a request has been file, we have no workarounds or solutions at this time and it could take months before a solution from our development team comes.

At this moment there is nothing else we can do on this matter as our development team is aware of the issue.

Thanks,
Shane