Tell us what you are trying to do?
I am using Real Estate demo. I Created a layout for property details. In the layout there is three tabs first one contains the content template for property. The second one contains rentals view. I want to set condition in the layout such that it can be displayed for a specific user role. In this case only the post owner can see the rentals tab.
Hi there,
Thank you for contacting us and I'll be happy to assist.
The "Tabs" widget in the Layouts plugin doesn't support this conditional control feature, out-of-the-box, but you can follow this workaround:
1. In your Rental tab's settings, please include a custom class e.g. "rental-tab", as shown in these screenshots:
Screenshot A: hidden link
Screenshot B: hidden link
2. Next, at the bottom of that layout, include a new "Single Widget" and select a "Custom HTML" type widget.
Screenshot: hidden link
3. In the content of this new widget, you can include some Custom CSS code, which conditionally works to show the rental tab, if the current user is also the author of the current post and if not, hide it:
Screenshot: hidden link
[wpv-conditional if="( '[wpv-post-author format="meta" meta="ID"]' eq '[wpv-user field="ID"]' )"]
<style type="text/css">.nav.nav-tabs .rental-tab { display: block !important; }</style>
[/wpv-conditional]
[wpv-conditional if="( '[wpv-post-author format="meta" meta="ID"]' ne '[wpv-user field="ID"]' )"]
<style type="text/css">.nav.nav-tabs .rental-tab { display: none !important; }</style>
[/wpv-conditional]
You can learn more about how output works in Toolset from this guide:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
I hope this helps and please let me know how it goes.
regards,
Waqar
My issue is resolved now. Thank you!