Custom user field, if checkbox user ...

Allan

Well-known member
I have create an custom user field:

Screenshot_18.webp Screenshot_19.webp

Screenshot_20.webp


My html code:

Code:
<xen:if is="{$user.customFields.bloc_note} == 'on'">
hide or show this content if custom user field checked
</xen:if>

I would like if the user checks the box, the content is displayed.

But actually, don't work :(
 
This should work..

Code:
<xen:if is="{$user.customFields.bloc_note.on}">
hide or show this content if custom user field checked
</xen:if>
 
The current user is $visitor, not $user !
Code:
<xen:if is="{$visitor.customFields.bloc_note.on}">
hide or show this content if custom user field checked
</xen:if>
 
Works every time in some quick tests here.

There's either something else you're not telling us or $user isn't available where you're using it.

EDIT: Or like @Insy said, you want $visitor, not $user.
 
Code:
<xen:if is="{$visitor.customFields.bloc_note.on}">
hide or show this content if custom user field checked
<xen:else />
Show stuff here for people with option not checked
</xen:if>
 
Code:
<xen:if is="{$visitor.customFields.bloc_note.on}">
hide or show this content if custom user field checked
<xen:else />
Show stuff here for people with option not checked
</xen:if>
Tried and don't work because if the user don't want to see the block, it will see still ..
 
So, what exactly are you trying to do? If a field is not set by default then the "<xen:else />" will run. It should work, but without seeing the actual code we have no idea.

EDIT: You can try this as well.

Rich (BB code):
<xen:if is="{$visitor.customFields.bloc_note.on} == 'on'">
hide or show this content if custom user field checked
<xen:else />
Show stuff here for people with option not checked
</xen:if>
 
So, what exactly are you trying to do? If a field is not set by default then the "<xen:else />" will run. It should work, but without seeing the actual code we have no idea.

EDIT: You can try this as well.

Rich (BB code):
<xen:if is="{$visitor.customFields.bloc_note.on} == 'on'">
hide or show this content if custom user field checked
<xen:else />
Show stuff here for people with option not checked
</xen:if>
It work ! Thank you Steve F ;)

Just for understand

In <xen:if is="{$visitor.customFields.bloc_note.on} == 'on'">

-> bloc_note -> custom ID field
-> on -> Value to ID field

And 'on' -> Activate ? it's correct ?

And if i put off ? -> no activate ?
 
Back
Top Bottom