Skip Navigation

[Resolved] Bug report: Toolset generated conditional for user role incorrect

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

Problem:
When I insert a Conditional with the GUI and choose to compare a ShortCode that usually accepts attributes, those are not editable in the GUI and the conditional inserted will not work due to that.

Solution:
After inserting the conditional, you can highlight the ShortCode and edit it again with the "Fields and Views" Button, and choose the exact attribute settings you want.

Relevant Documentation:
https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

This support ticket is created 6 years, 9 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.

Sun Mon Tue Wed Thu Fri Sat
- - 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00 14:00 – 20:00
- - - - - - -

Supporter timezone: Asia/Ho_Chi_Minh (GMT+07:00)

This topic contains 5 replies, has 2 voices.

Last updated by Evan Seplow 6 years, 9 months ago.

Assisted by: Beda.

Author
Posts
#537795

Trying to generate a conditional to check user role before showing a post/page:

1 - On a page/post: Click on "Conditional Output" button on toolbar.
2 - A window opens - On the dropdowns, choose "Views Shortcodes", "wpv-current-user" = 'author'
3 - The code it generates is:

[wpv-conditional if="( '[wpv-current-user]' eq 'author' )"]  ANYTHING HERE [/wpv-conditional]

Which does not seem to be correct. At least it does not work. The correct code it should generate seems to be:

[wpv-conditional if="( '[wpv-current-user info="role"]' eq 'author' )"] AUTHOR [/wpv-conditional]

At least, in my testing, the second one works. So I assume your system is generating the wrong code.

BONUS:
For anyone else reading this, another alternative can be to click on the ACCESS button in the toolbar and choose roles to check there. It will generating working code such as:

[toolset_access role="Author,Contributor,Subscriber,Guest" operator="allow" raw="true"] ANYTHING HERE [/toolset_access]
#537984

That is not a BUG.

We have plans to enhance the GUI to also choose attributes of the ShortCodes, but this is not yet done.

For now, you need to manually edit the ShortCode after inserting the conditional.

That way you can then address the exact attribute you want.

Your approach is 100% correct, as long the GUI does not provide those features.

Thank you

#538040

Hi Beda,

Thank you for your reply. Yours are always thoughtful, logical and helpful.

I'm sure BUG is too strong since the programming itself is not in error. But certainly if a user is trying to achieve a goal, and this function produced code that doesn't work, then the misdirection can cause hours of frustration to the end-user. I believe the entire goal of having this helper application is to make life easier for novice users, not frustrate them more. Perhaps when this specific use-cases come up you guys need to add messages or other helper - or just produce working code.

No big deal to me here. I already know how to fix it for myself. Just trying to help you in your goal to make toolset as friendly and usable as possible. So I figured I report it. : )

#538041

PS:

And there is no longer a "Report a Bug" function in this forum (That I see, anyway). Whereas "I need help with toolset" and "Help me solve a problem" seem to be redundantly the same thing.

#539506

You are absolutely correct about the user friendliness.

About the Bug reports, thank you for helping me here, this is also my opinion and I tried to push that, at no avail.
I will try to push again for a better way of reporting issues.

This thread will help me to make it heard 🙂

#539675

Just trying to help. I'm a fan of the efforts of you and your team.

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