Skip Navigation

[Cerrado] Conditional on user role doesn't work

This support ticket is created hace 1 año, 7 meses. 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.

Hoy no hay técnicos de soporte disponibles en el foro Juego de herramientas. Siéntase libre de enviar sus tiques y les daremos trámite tan pronto como estemos disponibles en línea. Gracias por su comprensión.

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)

Este tema contiene 4 respuestas, tiene 2 mensajes.

Última actualización por Minesh hace 1 año, 7 meses.

Asistido por: Minesh.

Autor
Mensajes
#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

Idiomas: Inglés (English )

Zona horaria: 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

Idiomas: Inglés (English )

Zona horaria: Asia/Kolkata (GMT+05:30)

Once I loggedin to your site I visit the following page:
=> enlace oculto

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

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

Idiomas: Inglés (English )

Zona horaria: 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.

El debate ‘[Cerrado] Conditional on user role doesn't work’ está cerrado y no admite más respuestas.