Skip Navigation

[Closed] Conditional on user role doesn't work

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)

This topic contains 4 replies, has 2 voices.

Last updated by Minesh 12 months ago.

Assisted by: Minesh.

Author
Posts
#2598763

I've created a conditional block that checks whether the current user role is administrator or editor. However, when executed, it strips the "current user role" from the comparison per the debug:

####################
wpv-conditional attributes
####################
Array
(
    [if] =>   ( ( '' = 'administrator' ) OR ( '' = 'editor' ) ) 
    [debug] => true
)

####################
Debug information
####################
--------------------
Original expression:   ( ( '' = 'administrator' ) OR ( '' = 'editor' ) ) 
--------------------
After replacing 1 general variables and comparing strings: ( ( '' = 'administrator' ) OR ( '' = 'editor' ) )
	Comparing  to administrator
After replacing 2 general variables and comparing strings: ( ( '' = 'administrator' ) OR ( '' = 'editor' ) )
	Comparing  to editor

Switching to the advanced conditional editor on the block didn't help. I also tried using a content template block with the same conditionals in the content template classic editor:

[wpv-conditional if="( '[wpv-current-user info="role"]' eq 'administrator' ) OR ( '[wpv-current-user info="role"]' eq 'editor' )" debug="true"]
MY CONTENT
[/wpv-conditional]

The debug information remains the same. Any ideas why [wpv-current-user info="role"] is getting stripped out of the expression?

#2598925

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

First of all, based on the debug information you shared I find that you are using the outdated Toolset plugins. We always recommend running your site with the latest stable release plugin version.

*** Please make a FULL BACKUP of your database and website.***

Could you please update ALL Toolset plugins to it's latest officially released version. You can download the latest plugin release from your accounts page:
=> https://toolset.com/account/downloads/
OR
You can install/update Toolset plugins using the installer plugin:
-https://toolset.com/faq/how-to-install-and-register-toolset/#automatic-installation-once-you-have-otgs-installer-plugin-installed

Once you update all Toolset plugins to latest release - Can you please make sure you are checking the condition where you already loggedin?

If it does not work - please share problem URL where you added the conditional statement as well as admin access details.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#2599505

Minesh
Supporter

Languages: English (English )

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

Once I loggedin to your site I visit the following page:
=> hidden link

And I can see that administrator role is available for comparison. Please check the following screenshot: hidden link

Can you please make sure you are loggedin when you try to visit the above page and if you are loggedin you are loggedin using what role.

#2601645

Do you see any reason why this conditional runs correctly for you and my admin user account, but not for the admin user Kayla? The debug is still running as blank when she is logged in. She's the user who created the page and conditional block, if that makes a difference.

#2602073

Minesh
Supporter

Languages: English (English )

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

I'm not sure why its happening. I tried to login using the "toolsetsupport" account but now I'm not able to login to admin.

What if you create a new user and check if the conditional works with new user.

The topic ‘[Closed] Conditional on user role doesn't work’ is closed to new replies.