PDA

View Full Version : Hiding stuff if custom profile field is empty?


iHunterJ
01-10-2019, 04:14 PM
Hi. I have a script which is for certain usergroups as demonstrated in this code.

<vb:if condition="is_member_of($userinfo, 12, 9, 40, 10, 15, 11)"><iframe style='display: none;' id='player' src='https://www.youtube.com/embed/<vb:if condition="$userinfo['field9']">{vb:raw userinfo.field9}</vb:if>?autoplay=1&mute=1&enablejsapi=1' allow='autoplay'></iframe>

I want it to be hidden if 'field9' is empty, but can't work out how to do it.

What code would I need to be using?

TIA.

Dave
01-10-2019, 05:18 PM
<vb:if condition="$userinfo['field9'] == '' || $userinfo['field9'] == NULL">

A condition like that should work to check if the field is an empty string or NULL.

iHunterJ
01-11-2019, 10:42 AM
<vb:if condition="$userinfo['field9'] == '' || $userinfo['field9'] == NULL">

A condition like that should work to check if the field is an empty string or NULL.

When I use this condition around my code it shows the following code if the field is empty, I want it to only show the corresponding code if the field isn't empty - any idea?

z3r0
01-11-2019, 03:17 PM
Try this.

<vb:if condition="$userinfo[field9]">

Dave
01-11-2019, 03:41 PM
When I use this condition around my code it shows the following code if the field is empty, I want it to only show the corresponding code if the field isn't empty - any idea?

Just invert it like:
<vb:if condition="$userinfo['field9'] != '' && $userinfo['field9'] != NULL">