Skip Navigation

[Resolved] Show delete post button in view based on Access group

This thread is resolved. Here is a description of the problem and solution.

Problem:
The issue here is that the user's access shortcode wasn't working when evaluating the user's role to conditionally display their delete button.

Solution:

In this case the user was evaluating a user role that had a space e.g Super Admin.

When you're evaluating this in our access shortcode you will need to use the slug of the user role which will be super_admin.

Your final shortcode should be.

[toolset_access role="super_admin" operator="allow" raw="true"]
My delete post button
[/toolset_access]
This support ticket is created 2 years, 6 months ago. There's a good chance that you are reading advice that it now obsolete.

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)

This topic contains 4 replies, has 2 voices.

Last updated by Pierre 2 years, 6 months ago.

Assisted by: Shane.

Author
Posts
#2201721
nobutton.png
Skärmavbild 2021-10-21 kl. 15.49.58.png

Tell us what you are trying to do?
I list post items in a table view. The last column should have a "Delete"-button that is only visible for those users who belong to an access group called "Boatman admin".

Is there any documentation that you are following?
Yes. I found this post: https://toolset.com/forums/topic/displaying-content-based-on-access-group/ but when I add a "Text and field" item and change it into HTML - add the code:
[toolset_access role="Boatman admin" operator="allow" raw="true"]
My delete post button
[/toolset_access]
Nothing shows up in my view?

#2202061

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

HI Pierre,

Thank you for getting in touch.

I'm assuming Boatman and admin are 2 different roles correct?

If so then you should add them with a comma like this.

[toolset_access role="Boatman, admin" operator="allow" raw="true"]
My delete post button
[/toolset_access]

Now it should be noted that this is done based on the User's Role and not the user group. We don't have a way to conditionally display the button based on the user group.

Thanks,
Shane

#2202091

Hi Shane,
No ”Boatman admin” is the name of the role.
Perhaps a space in it doesn’t work?

#2202093

Shane
Supporter

Languages: English (English )

Timezone: America/Jamaica (GMT-05:00)

Hi Pierre,

In that case then the role would've been created with an underscore as the name. The code below should now work.

[toolset_access role="boatman_admin" operator="allow" raw="true"]
My delete post button
[/toolset_access]

Thanks,
Shane

#2202993

My issue is resolved now. Thank you!

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.