I created several custom user fields that I want to show at a page only if those are not empty. As I can't find custom user fields in the drop down list of the Conditional block I am using the advanced editor.
It works fine as long as the custom user field is a single line text field. But for the field type 'telephone' I do not succeed. I am using the following code:
[wpv-conditional if=" NOT ( empty( [types usermeta='festnetz' current_user='true'][/types]) ) " ]<br>Tel. [types usermeta='festnetz' current_user='true'][/types][/wpv-conditional]
where 'festnetz' contains a phone number. It returns null independant wether the test is against Empty or Not Empty.
I need help on the proper code.
Thanks
Hi,
Thank you for contacting us and I'd be happy to assist.
I've tested the conditional code that you've shared on my test website and it works as expected.
Can you please make sure that the user field slug that you're using is correct?
In case the issue still persists, you're welcome to share temporary admin login details along with the page where this conditional block is in use.
Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.
regards,
Waqar
Thank you for sharing these details.
The "empty" conditional check is failing in this case because the phone field contains numbers with spaces.
In such cases, it would be better to change the empty check from:
[wpv-conditional if=" NOT ( empty( [types usermeta='festnetz' current_user='true'][/types]) ) " ]
<br>Tel. [types usermeta='festnetz' current_user='true'][/types]
[/wpv-conditional]
To:
[wpv-conditional if="( '[types usermeta='festnetz' current_user='true'][/types]' ne '' )"]
<br>Tel. [types usermeta='festnetz' current_user='true'][/types]
[/wpv-conditional]
Related guide:
https://toolset.com/documentation/legacy-features/views-plugin/checking-fields-and-other-elements-for-emptynon-empty-values/
It's so easy when you know where to look! Thanks for the help!