Archived topic
Exclude user role from hook
5 replies · Started by Sam on February 25, 2020
Hi, is there a way to exclude user roles from hooks? I see you can exclude locations.
I would like to exclude user role administrator for a hook.
thanks
Sam
Hi there,
You can't exclude them, but you can include them: https://docs.generatepress.com/article/hooks-element-overview/#display-rules
That means you can choose the rules you want to apply the Hook to.
Otherwise, you'd need to use a filter to exclude a role.
Hi Tom, ok noted. Would you mind confirming the below logic is correct? To apply the hook to either logged out users or woocommerce customers, I should include only "logged out users" and "customers". And this would then exclude all other users?
What about if a "customer" was logged in would it still include then because the role is set?
thanks
Sam
The logic uses "or", so if one of the conditions is met, it should display.
Let me know if you need more info :)
OK thanks for your help.
No problem :)