XF 2.2 Flags country of origin and country of residence

CoinBit

Member
Hello,

My community is eager to have flags displayed under user profiles, representing both their country of origin and country of residence. While I'm aware of IP-based solutions, I prefer a method where users select their countries during registration. Creating custom fields with a list of countries is feasible, but I specifically want the flags to be displayed based on user selections. I've explored a tutorial designed for Xenforo 1, but it doesn't work for Xenforo 2.2. Any suggestions or alternatives would be greatly appreciated.


I am aware that we can create custom fields add the list of countries and then let the user choose the country. It will display the name of the country but will not switch to the flag. I think there must be an easy solution for it as I should be able to add the code in the HTML box of the custom fields which lets me choose the flag based on the user's selection

Thank you
 
Hi Andy,

I have already tried this add-on but it doesn't work very well. It only selects 1 flag and that too from the list of flags not like a drop-down list of countries with flags automatically assigned. Any customisation suggestions?

I think one way of doing is by uploading 200 flags of countries, then in the HTML display I could write instructions if a userA chooses UK then it must add the UK flag. Something like that?
 
Last edited:
I think you can do it with customer user fields. Force users to select their country during registration by making the fields required. Here's how I did it:

1- I created a 'custom user field' called country like attached screenshot. (note the "wrapper display HTML" Make ur path relative to your site) -->Maybe also add {$title} in front of yours since you'll need to label each because you'll have 1 for country of residence and 1 for country of origin.
2- I made the 'options for choice fields' all the countries like attached (mannnnny more countries too of course lol)
3- I uploaded the flag images to my server into the directory I wrote in the wrapper display HTML like the attached image. Note that each gif file name is the same text I used in choice field value column.
4- It displays in the user info area like attached.

Hope that helps!
 

Attachments

  • country.webp
    country.webp
    56.1 KB · Views: 14
  • countrychoices.webp
    countrychoices.webp
    16.8 KB · Views: 11
  • countryflags.webp
    countryflags.webp
    46 KB · Views: 11
  • countrylooks.webp
    countrylooks.webp
    4.3 KB · Views: 11
I think you can do it with customer user fields. Force users to select their country during registration by making the fields required. Here's how I did it:

1- I created a 'custom user field' called country like attached screenshot. (note the "wrapper display HTML" Make ur path relative to your site) -->Maybe also add {$title} in front of yours since you'll need to label each because you'll have 1 for country of residence and 1 for country of origin.
2- I made the 'options for choice fields' all the countries like attached (mannnnny more countries too of course lol)
3- I uploaded the flag images to my server into the directory I wrote in the wrapper display HTML like the attached image. Note that each gif file name is the same text I used in choice field value column.
4- It displays in the user info area like attached.

Hope that helps!
Excellent, Superb, Amazing

You successfully addressed the issue I had been grappling with for multiple days. You are a genius. I was thinking on the same lines for the last few days but it wasn't working for me. But now with your help, I was able to address this issue.


Screenshot 2024-01-09 102523.webp

My advice for others who may need this in future is to use the code in the first block instead of the second block as shown in your post.

Screenshot 2024-01-09 103309.webp


Thank you once again
 
Back
Top Bottom