Problem: I have created a Form to edit a post, and I would like to display the Edit Post Form link to only site admins and to the post author. Other site visitors should not see this link.
Solution: Use a combination of Access Control shortcodes and conditional HTML to handle the conditional display of this link.
[wpv-conditional if="( [wpv-post-author format='meta' meta='id'] eq [wpv-current-user format='meta' info='id'] )"] Current User is post author. [toolset-edit-post-link layout_slug='program-edit-layout' target='self']Edit %%POST_TITLE%%[/toolset-edit-post-link] [/wpv-conditional] [toolset_access role="Administrator" operator="allow"] [wpv-conditional if="( [wpv-post-author format='meta' meta='id'] ne [wpv-current-user format='meta' info='id'] )"] Current User is admin but not author: [toolset-edit-post-link layout_slug='program-edit-layout' target='self']Edit %%POST_TITLE%%[/toolset-edit-post-link] [/wpv-conditional] [/toolset_access]
Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/
https://toolset.com/documentation/user-guides/access-control-texts-inside-page-content/
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-post-author
https://toolset.com/documentation/user-guides/views-shortcodes/#wpv-current-user
This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.
Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | 8:00 – 12:00 | - | - |
13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | 13:00 – 17:00 | - | - |
Supporter timezone: America/New_York (GMT-04:00)
This topic contains 2 replies, has 2 voices.
Last updated by 5 years, 3 months ago.
Assisted by: Christian Cox.