How can attributes in a single HivePress listing be shown or hidden based on visitor context?
Example: a website asks visitors on entry whether they are Job Seeker or Employer, and based on that selection, the same listing displays different attributes or sections tailored to that visitor type.
Thanks for your message — our team will reply shortly.
In the meantime, you can also get instant help from our AI Assistant, familiar with all the docs and solutions we’ve shared over the years.
Hi,
Apologies for the long reply, we received more requests than expected.
Unfortunately, this feature isn’t available out of the box, but it’s possible with customizations.
For your specific use case, there might be a workaround, you could separate the entities by using Requests so that businesses post what they’re looking for, while candidates post listings as their CVs/resumes.
If that doesn’t work for you, we can provide general development guidance to point you in the right direction. If you don’t have a developer or aren’t familiar with custom development, we’d recommend reaching out to verified freelancers who can help implement this: Customize your website | HivePress.
Thanks for response.
To make it clear, both visitors view same listing but couple of attributes are hidden from one user. Example when you open website it ask are you company or job seeker and you see listing by admin or vendor with slight attribute visibility. All about viewing.
Thanks for the details.
At the moment, HivePress doesn’t have built-in conditional logic for showing or hiding attributes based on user roles.
This can be achieved with a bit of customization. You can use the
hivepress/v1/models/listing/fields filter, which allows you to modify listing fields programmatically. The callback function receives and returns an array of fields, so you can adjust specific attributes depending on the current user’s role.
For example, you can check the user role or capabilities using something like current_user_can( 'edit_posts' ) (this is typically true for vendors, while regular users/job seekers won’t have this capability). Based on that condition, you can modify the attribute settings.
If you want to hide an attribute for certain users, you can set its display_template to an empty value or replace it with a custom placeholder text (e.g. “Hidden”), depending on your use case.
Here’s an example of such a snippet. I have an attribute named Condition, and this snippet hides it for regular users.
add_filter(
'hivepress/v1/models/listing/fields',
function ( $fields, $model ) {
if ( isset( $fields['condition'] ) ) {
if ( ! current_user_can( 'edit_posts' ) ) {
$fields['condition']['display_template'] = '%label%: hidden';
} else {
$fields['condition']['display_template'] = '%label%: %value%';
}
}
return $fields;
},
1000,
2
);
Hope this helps.
I’m not currently looking to do this myself, but thanks for sharing a solution, @kseniia - things like this really help to get my creative juices flowing! ![]()
Cheers,
Chris ![]()
Glad to help!
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.