• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Custom user field, if checkbox user ...

Allan

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

Screenshot_18.png Screenshot_19.png

Screenshot_20.png


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 :(
 

Insy

Well-known member
#4
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>
 

Snog

Well-known member
#5
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.
 

Steve F

Well-known member
#10
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>
 

Allan

Well-known member
#11
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 ..
 

Steve F

Well-known member
#12
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.

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>
 

Allan

Well-known member
#13
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.

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 ?