Hi,
I'm searching for a way to dynamically filter a view by the current user role. Any idea of how to achieve that ?
You need to create custom code for the frm_where_filter hook. If you follow this example, https://formidableforms.com/knowledgebase/frm_where_filter/#kb-stop-user-id-filter-for-admins, instead of using current_user_can(), use one of the role specific WordPress functions: https://developer.wordpress.org/?s=user+role. YOu can also write your own shortcode to retrieve a user role and use the shortcode directly in the view builder filter.
Thank you Victor for your help!
Here's a little more. I remembered this morning that I have this public snippet to validate against a field against a user role. You can adapt this for your view filter code.
https://formidable-masterminds.com/conditionally-require-fields-by-user-role/
Please login or Register to submit your answer