Skip Navigation

[Résolu] « wpv-conditional » function not working correctly

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem:
Allow content accessible to only users having "administrator" role OR display conditional content based on "Administrator" role

Solution:
You can use [wpv-conditional] shortcode or if you have installed the access plugin than you can use [toolset_access] shortcode to display conditional content based on "Administrator" role.

You can find proposed possible solution with the following reply:
=> https://toolset.com/forums/topic/wpv-conditional-function-not-working-correctly/#post-617810

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

This support ticket is created Il y a 6 années et 2 mois. 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
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

Marqué : ,

This topic contains 4 réponses, has 2 voix.

Last updated by rodneyM Il y a 6 années et 2 mois.

Assisted by: Minesh.

Auteur
Publications
#617706

In the website I have a conditional statement
[wpv-conditional if="( '[wpv-current-user info="login"]' eq 'NAME' )"]<a href="PAGE]"> PRINT</a> [/wpv-conditional]
It has allowed only me as administrator to see the contents and has worked since it has gone live for 3 years.
The command PRINT has appeared to all visitors twice now, the first time it was sorted after updating plugins but it has happened again and all plugins are up to date. (there is very sensitive information now available to others)
I am not sure what has gone wrong, I have had to close the site down still this is sorted.

#617810

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - instead of using [wpv-conditional] shortcode here, could you please try following code:

[toolset_access role="Administrator" operator="allow"]
<a href="PAGE]"> PRINT</a> 
[/toolset_access]

OR

Another way is:

.
[wpv-conditional if="( '[wpv-current-user info="role"]' eq 'administrator' )"]
<a href="PAGE]"> PRINT</a> 
[/wpv-conditional]

More info:
=> https://toolset.com/documentation/user-guides/conditional-html-output-in-views/

#618167

while the toolset_access role="Administrator" code produces the print command on a separate line, it works, the revised conditional one didn't work.
Can I be sure that the Print command will not appear to guests or an author.
If I don't log out does that code still stay and allows unauthorised access

#618171

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Yes - the code will be accessible to administrators only with [toolset_access] shortcode.

Well - [wpv-conditioanl] shortcode should work also.

If I don't log out does that code still stay and allows unauthorised access
==> Well - if you are loggedin as administrator and didnt logged out that means administrator user is there and eventually it will have access and its expected behavior as you are currently logged in as administrator and didnt logged out.

#618452

Will give it a go for a while and hopefully guests will not see the "PRINT" command.

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