Skip Navigation

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

This support ticket is created 4 years, 8 months ago. 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.

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)

This topic contains 2 replies, has 2 voices.

Last updated by Darryl 4 years, 8 months ago.

Assisted by: Luo Yang.

Author
Posts
#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!