Skip Navigation

[Resuelto] An apostrophe in a user name used in a conditional statement will fail

This support ticket is created hace 4 años, 9 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
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9: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/Hong_Kong (GMT+08:00)

Etiquetado: ,

Este tema contiene 2 respuestas, tiene 2 mensajes.

Última actualización por Darryl hace 4 años, 8 meses.

Asistido por: Luo Yang.

Autor
Mensajes
#1538009

The conditional statement:

[wpv-conditional if="( '[wpv-post-author]' eq '[wpv-current-user]' )"]

will fail if the user name is something like Bob O'Leary with an apostrophe in the name.

I've seen posts here stating that using a backtick can be a workaround, but this is someone's name that they have entered so it's out of my control.

In this particular case I created a workaround with:

[wpv-conditional if="( '[wpv-post-author format="meta" meta="user_login"]' eq '[wpv-user field="user_login"]' )"]

which works for me because the login usernames are created programmatically and only use numbers.

#1538361

Hello,

Thanks for sharing the workaround, that will help other users.

And it is a known issue, see our document:
https://toolset.com/documentation/user-guides/views/conditional-html-output-in-views/#field

You should avoid using apostrophes like ' and " in Values you compare with HTML conditionals.

#1545961

My issue is resolved now. Thank you!