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

XF 1.2 User Location

Floyd R Turbo

Well-known member
#1
Just converted from vB and I had done something that:

1) forced the user to specify their location (city, state, country, etc) upon registration

and

2) displayed this below their username on each post

Is it possible to make this happen in XF and if so, how?
 

Floyd R Turbo

Well-known member
#3
Well the "location" field already exists. So I wanted to make that a required field and then display it by the user avatar on each post.
 

Floyd R Turbo

Well-known member
#5
Can it be hidden? then I could create the custom field and make that mandatory. Then I would just need to know how to display the contents on each post
 

Brogan

XenForo moderator
Staff member
#7
You could edit the template(s) to remove the default field.
Then create a custom field and use the style property option to display it below the avatar.
 

Floyd R Turbo

Well-known member
#8
Newbie warning here. My programming experience started with BASICA in the mid 80s and ended with FORTRAN in high school in the 90s. I can follow directions well but figuring it out on my own is dangerous at best.:eek:

So a little more detail or a point to a helpful similar thread would be awesome

Thanks!!
 

Brogan

XenForo moderator
Staff member
#9
Well first you need to tell me where you want to remove the default field from and I can tell you which templates to edit.

Then you just set up a custom field and show it under the avatar by checking Style Properties: Message Elements -> Show custom user fields
 

Floyd R Turbo

Well-known member
#12
Cool, thanks. I'll try that in a bit. Another question: most users have this field filled in already. So can I create the custom field and the transfer the information en mass before disabling the default field? Does that have to be done by editing the table in the DB? Only 190 users so if it has to be manual, it's not a big deal. Just looking for a shortcut
 

Brogan

XenForo moderator
Staff member
#13
You could do it with a query or manually editing the field in the ACP under the Personal Details tab for each member.
 

Brogan

XenForo moderator
Staff member
#15
You would need to query the existing field and then insert into the new field, making sure to match the user IDs.
 

Floyd R Turbo

Well-known member
#16
I was able to create the custom field, no problem. I am able to comment out the default field, no problem.

I can find the default field in the SQL database under xf_user_profile -> location, no problem

I can find the new custom field xf_user_field_value -> field_id = userlocation (my name for it), no problem

Where I get stuck is how to copy the information. I'm thinking that I could get this done manually quicker.

Another possible issue though, I have noticed that quite a few people do not have anything in the default location field. This is because on the old vB forum, it was not flagged as a required field. So will this cause any issue for existing users?
 

Brogan

XenForo moderator
Staff member
#17
If it's a required field, the next time they edit their profile they will be prompted to complete the field before they can save.
 

Floyd R Turbo

Well-known member
#18
Cool

I think I figured out the way to edit the DB. I'm an excel whiz so I exported a few tables so I can match up uesrnames/IDs with the fields, then add the new rows with field_id -> userlocation information and arrange it properly so it matches the current structure, then import it. Of course a backup prior....