• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Using Custom User Fields to customise the layout

Using Custom User Fields to customise the layout

Brogan

XenForo moderator
Staff member
#1
Brogan submitted a new resource:

Using Custom User Fields to customise the layout - Allow your members to choose which content they want to see

This guide will explain how to allow your members to choose which elements they wish to see, enhancing their forum experience.

For an explanation of both features, see the following pages of the help manual:
https://xenforo.com/help/custom-user-fields/
https://xenforo.com/help/templates/


It is impossible to please all members all of the time as far as site design, layout, and functionality is concerned.
Sometimes it's not possible to please any of them any of the time.
Read more about this resource...
 

dutchbb

Well-known member
#2
Code:
<xen:if is="!{$visitor.customFields.profileposts}">
How can we add another conditional to this, for example usergroup?
 

Brogan

XenForo moderator
Staff member
#3
You can just use AND to combine conditional statements.

However, as presumably you want to limit it to 'premium' user groups, your users may question why the customisation isn't being applied, as it won't stop the field appearing on their account preferences page.
 

dutchbb

Well-known member
#4
The goal is to show ads to everyone except premium members who also have checked 'hide ads' in their settings. :)
 

Brogan

XenForo moderator
Staff member
#5
Yes, that will work but the checkbox will still be shown to non premium members.

It also seems odd that premium members would choose to show ads...
 

dutchbb

Well-known member
#6
Yes, that will work but the checkbox will still be shown to non premium members.

It also seems odd that premium members would choose to show ads...
I know we have it that way in vb, the idea of non premium members seeing it is they will become interested in premium membership (we put these 'premium members only' links below added features). Some premium members actually want to see the sponsor ads to know about the bargains. However Adsense is always hidden for them and everyone over 300 posts.
 

dutchbb

Well-known member
#8
Does this not work in the template ad_above_content ? I have used this code:

Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 3, 5, 6, 7, 13, 15} AND !{$visitor.customFields.advertenties}">
It's always hiding now.
 

Brogan

XenForo moderator
Staff member
#9
You can dump it in the template to see if it's available.
Code:
{xen:helper dump, $visitor.customFields.advertenties}
It should be as it's part of the $visitor array.
 

dutchbb

Well-known member
#10
Does this not work in the template ad_above_content ? I have used this code:

Code:
<xen:if is="!{xen:helper ismemberof, $visitor, 3, 5, 6, 7, 13, 15} AND !{$visitor.customFields.advertenties}">
It's always hiding now.
For anyone interested, this is the working code:
Code:
<xen:if is="{xen:helper ismemberof, $visitor, 3, 5, 6, 7, 13, 15} AND {$visitor.customFields.hide_google_ads}">

*keep empty* (show no banner)

<xen:else />

*put Adsense code here* (show banner)

</xen:if>
This allows premium members/mods/admins etc to switch off banners or show them. Other user groups still see/can check the checkbox but it will not work until they upgraded their account.
 

Isil`Zha

Active member
#11
hmm, I'm trying to give users an option for disabling or enabling margins on .pageWidth, but it seems to not be recognizing my custom field ID (in EXTRA.css)

Code:
<xen:if is="{$visitor.customFields.noMargins}">
    .pageWidth
    {
        margin: 0px 0%;
    }
</xen:if>


The option does appear in the preferences, but it's acting as if the custom field ID doesn't exist. Checking the option does nothing, and if I change the conditional to <xen:if is=!... it does what I expected it to do , but the actual preference checkbox continues to do nothing (it would then be stuck with the lack of margins regardless of what's selected.)
 

Andrej

Well-known member
#12
EXTRA.css doesn't support such conditional statements. You have to edit the relevant template directly.
 
Last edited:

Isil`Zha

Active member
#13
EXTRA.css doesn't support conditional statements. You have to edit the relevant template directly per the instructions.
Odd, it says it I can use XenForo template syntax at the bottom. :( I'm not that great with CSS, do you know what template that would be? I already tried inserting it into PAGE_CONTAINER (I didn't see it in forum_list) under <div class="pageWidth"> but it doesn't do anything when placed there.

EDIT: Whoops, wrong place
 
Last edited:
#14
I want to create a custom user field but i need to set the field in such a way that once user inputs a value and submit, another user on the website cannot input similar value.

For example, when user A inputs 'abcd@email.com' in the email field in the contact details, user B cannot use same 'abcd@email.com' in his email field.

Now, my question is that how do i create a custom field that work in this way