XF 1.1 if condition for custom profile fields?

Luxus

Well-known member
I have made a custom profile field and need to <xen:if it. The ID of the field is "country". Now I am looking for a condition similar to this:


Code:
<xen:if customprofilefield="country">
bla bla
</xen:if>

Is this possible?
 
Luxus, you're looking for something like this:

Code:
<xen:if is="{$user.customFields.country}">
If the field has data this text will be shown
</xen:if>

or

Code:
<xen:if is="{$user.customFields.country} == 'United Kingdom'">
If the field contains 'United Kingdom' this text will be shown
</xen:if>
 
Another question. Is this above possible with user ranks/titles?
I tried

Code:
<xen:if is="{$userTitle.rookie}">bla bla</xen:if>
Code:
<xen:if is="{$user.userTitle.rookie}">bla bla</xen:if>
Code:
<xen:if is="{$user.userTitle} == 'rookie'">bla bla</xen:if>

but none of them is working.
 
Should be this:

Code:
<xen:if is="{xen:helper userTitle, $user} == 'rookie'">
YOU ARE A ROOKIE
</xen:if>

It is case sensitive so 'rookie' is different to 'Rookie'
 
It's worth adding:

As user titles are usually linked to usergroups, potentially another way of achieving this is:

Code:
<xen:if is="{xen:helper ismemberof, $visitor, 10}">
YOU ARE A ROOKIE
</xen:if>

Where 10 is the usergroup ID of people in the "rookie" group.

Even if that doesn't help, it's worth bearing in mind as it's useful!
 
Thank you :) The code is working, but I forgot a critical thing. All titles belong to the same group "Registered Users". By earning points users should get these user titles, but remain in the same group:
usertitles.webp
I wanted to add images for each of those user titles by using conditions. The issue here is that if users can change their custom title, the user rank images will then be changed too. If the Newcomer group has 1 star as rank image and the Member group 3 stars, members can decrease their stars by changing their user title to Newcomer and thus, faking their ranks. How can I fix it?
 
That will work, but I want to allow members to change their user titles.
Hm...does an condition exist for points?

Code:
<xen:if is="{xen:helper userPoints} == '50'">
user has the members rank</xen:if>
 
That will work, but I want to allow members to change their user titles.
Hm...does an condition exist for points?

Code:
<xen:if is="{xen:helper userPoints} == '50'">
user has the members rank</xen:if>
How about promoting people into different user groups when they reach certain point numbers?
 
That would work too and will probably be used by me if everything else fails. But I would like to keep every user in the same group if possible to save work. Also I believe a future version of XenForo will provide custom images for user ranks. Then it won't be necessary anymore to make usergroups for each rank.
 
Allright, I decided to distribute user rank images by trophy points. All I need now is the if condition that checks if a user has reached X points. I couldn't figure out the right code. Help is greatly appreciated :)
 
I have figured out the code.
Code:
<xen:if is="{$user.user_group_id} == 2 AND {$user.trophy_points} == 1"><p>user rank image</p></xen:if>

User Group 2 is for registered users. This prevents other special usergroups from getting rank images that are supposed to be for normal registered users only.
 
I have fugured out the code.
Code:
<xen:if is="{$user.user_group_id} == 2 AND {$user.trophy_points} == 1"><p>user rank image</p></xen:if>

User Group 2 is for registered users. This prevents other special usergroups from getting rank images that are supposed for normal registered users only.
Nice work!
 
Top Bottom