show button in a view with conditions

By: Andreas panagiotopoulos | Asked: 12/05/2022
ForumsCategory: Code Helpshow button in a view with conditions
Andreas panagiotopoulos asked 1 year ago
I have a view and I would like to have a button that duplicates the entry which should be available only to specific roles.. The button shoud be visible under role conditions.. How can this be done? Thank you!  
1 Answers
Bobby Clapp answered 1 year ago

Without doing anything, the form permissions can be defined to limit by role. So even if someone sees a button, it doesn't mean they can interact with the form. If you don't like the visual, you'll have to incorporate custom code or a plugin. If you go the plugin route, try members -> https://members-plugin.com/docs/shortcodes/

With the plugin you can wrap content up in a shortcode and limit it's visibility based on role among other things. Something like:

[members_access role="editor"]Hide this content from everyone but editors.[/members_access]

Making the Best WordPress Plugin even better - Together

Take on bigger projects with confidence knowing you have access to an entire community of Formidable Experts and Professionals who have your back when the going gets tough. You got this!
Join the community
crossarrow-right