Skip Navigation

[Résolu] An apostrophe in a user name used in a conditional statement will fail

This support ticket is created Il y a 4 années et 1 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
- 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)

Marqué : ,

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

Last updated by Darryl Il y a 4 années et 1 mois.

Assisted by: Luo Yang.

Auteur
Publications
#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!

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