Home › Toolset Professional Support › [Resolved] Hide/Show Tabs only current User/Author
Problem:
The issue here is that the user has an edit link shortcode that they only want to show to the author of the post being viewed.
Solution:
This can be done by wrapping the shortcode in our conditional.
Example
[wpv-conditional if="('[wpv-current-user]' eq '[wpv-post-author]' )"] Link goes here [/wpv-conditional]
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.
No supporters are available to work today on Toolset forum. Feel free to create tickets and we will handle it as soon as we are online. Thank you for your understanding.
Sun | Mon | Tue | Wed | Thu | Fri | Sat |
---|---|---|---|---|---|---|
- | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | 9:00 – 12:00 | - |
- | 13:00 – 18:00 | 13:00 – 18:00 | 13:00 – 18:00 | 14:00 – 18:00 | 13:00 – 18:00 | - |
Supporter timezone: America/Jamaica (GMT-05:00)
Tagged: Front-end display, Layouts plugin
This topic contains 12 replies, has 2 voices.
Last updated by Jaime 6 years, 1 month ago.
Assisted by: Shane.
Tell us what you are trying to do?
I need to Show two tabs when the current user is the author of the post and hide the tabs if the user is a visitor.
Is there any documentation that you are following?
Is would like to do something like this (https://toolset.com/forums/topic/show-a-button-only-current-user-author/) but with tabs.
Is there a similar example that we can see?
What is the link to your site?
I'm working on local
Hi James,
Thank you for contacting our support forum.
Could you be a little more specific on these tabs ? How were these tabs created.
Please let me know.
Thanks,
Shane
Hi Shane.
Thanks for your answer.
I'll try to be a little bit more specific now.
I made the tabs in a 'Template for post type', inside 'Layouts'. I create my tabs just adding some tabs in the composer.
What I need to do is:
I have a website wich has some Locations. I want that those Locations shows their public information (in tab 1) to everybody and show the edit form of this location (in tab 2) only to the owner of this location.
I've the tabs with information + edit form working all right. But my problem is I can't hide one tab to some users (just as you show in the example above https://toolset.com/forums/topic/show-a-button-only-current-user-author/)
How could I do this?
Thanks a lot Shane!
Hi Jaime,
Thank you for the clarity.
Unfortunately you're not able to hide the Tab itself, however you can restrict the form to only be accessed by the post author.
Would you like to do it like this instead?
Please let me know.
Thanks,
Shane
Oh...
So, if this is not possible, I would like to try another thing.
Maybe to show a conditional button that only appears to authors (Just like your example beside) linking to the edit form of the specific location.
I tried to do that with a simple link to another page that contains the edit form, but it gives me an 404 error.
Do you know how should I do that?
(To be clear.
What I want to do now is:
1. In a specific location there is a conditional button (show/hide to author/visitors)
2. When author click the button it goes to the Location Edit Form )
That would be a better solution than the tabs!
Thanks a lot Shane.
🙂
Hi Jaime,
To create the edit form you can follow the instructions below.
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/
Now to hide the link you can do this.
[wpv-conditional if="('[wpv-current-user]' eq '[wpv-post-author]' )"] Link goes here [/wpv-conditional]
Please try this and let me know if it helps.
Thanks,
Shane
Hi again Shane.
Ok. I had the edit form created to edit my posts (called "Locations").
It works ok, but only when I am in the same page (for example, in tab 1 I had the "Location" and in tab 2 I had the "Edit Location Form"). If I change from one Tab to another, it works great.
(That's why I asked you in the first time how to show tab 1 to authors and hide the tab 2 for visitors.
You told me that it's not possible to hide/show tabs. )
What I can't accomplish is use a button to send the author to the edit form I created.
It would be enough if I can do what I send you in the screenshot.
How should I do this button to send to the "Edit Location Form" of the specific "Location"?
And. Is it possible also to add an "Delete Location" button?
Thanks a lot Shane.
I'm sure you'll find a solution.
🙂
Hi Jaime,
With the link I sent below.
https://toolset.com/documentation/getting-started-with-toolset/publish-content-from-the-front-end/forms-for-editing/
This should guide you on how to do this by adding your edit form to a content template.
Once you have done this then you go to your view that you have listing the posts and Click on the Fields and Views button. Search for Edit.
Then insert the form Edit Post link.
For the Delete Post, you need to click on the Toolset Forms button above the editor then Add the Delete post button.
Please let me know if this is clear.
Thanks,
Shane
Thanks Shane!
It worked!
🙂
One last question.
How should I insert the link inside a button?
That's all!
Thanks again!
Hi Jaime,
Happy i'm able to assist so far.
Are you referring to the shortcode that is generated? Is it that you want to make this into a button ?
Please let me know.
Thanks,
Shane
Yes.
How should I insert the shortcode link to the Edit Form?
Thanks!
🙂
Hi Jaime,
What you will need to do is style it like a button.
Example using this CSS should give your link a button style.
.cred-edit-post { display: block; width: 115px; height: 25px; background: #4E9CAF; padding: 10px; text-align: center; border-radius: 5px; color: white; font-weight: bold; }
Please let me know if this helps.
Thanks,
Shane
My issue is resolved now. Thank you!