I’ve been experimenting a little with hivepress/v1/forms/listing_search but haven’t been able to figure it out. The use case is that I don’t want to display the search categories. I have two different roles. Role “Alice” should only be able to search category id 40. Logged out users and Role “Bob” should only be able to search for category 60.
Yes, it’s possible but requires customizations. If you mean hiding specific categories from the drop-down then hivepress/v1/forms/listing_search hook can be used. You can get the current user there (via wp_get_current_user()) and check the role, then unset categories (the code in the first snippet seems to be ok, it should unset options).
Please note that this will work only if you enabled the category drop-down in the main search form via Default Fields, otherwise the category filter appears in the listing_filter sidebar form.
Hi and thanks for your answer!
Actually, I don’t want to display the category drop down in the search field so in Hivepress → Settings → (Search) Default Fields (optional) I have removed the Categories.
The use case is a job board. I want employers to be able to create jobs and jobseekers to be able to create CVs.
I have two categories in hivepress: 1. CV 2. jobs
Only employers (user roles employer and premiumemployer) have access to the page findemployees.php. I want employers to be able to search for CVs there.
Not logged in users, logged in jobseekers (user roles worker and premiumworker) and employers (user roles employer and premiumemployer) have access to findjobs.php. On this page I only want to display jobs and not CVs.
Can you help me solve this problem? I don’t know what to ask for to be able to do this. Maybe you have a solution for me? I thought of maybe catching the search query and if you are on the page findjobs.php only search for the category jobs. The same with the findemployees.php, if the user role is employer or premium employer catch the query and display only CVs from the category CV.
How can I solve this? Maybe you want to create some built in function to be able to do this? Maybe the blocks for the search field where you can select which category or attributes to search would be a good idea?
thank you for the best directory plugin out there!