1. 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

Discussion in 'Styling and Customization Questions' started by Floyd R Turbo, Dec 6, 2013.

  1. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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?
     
  2. Brogan

    Brogan XenForo Moderator Staff Member

  3. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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.
     
  4. Brogan

    Brogan XenForo Moderator Staff Member

    The default fields can't be made mandatory.
     
  5. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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
     
  6. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    Or could I make a custom field mandatory and force the entry to the default location field?
     
  7. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  8. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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!!
     
  9. Brogan

    Brogan XenForo Moderator Staff Member

    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
     
  10. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    Personal details > location is the default field I want to disable, then I'll create the custom field
     
  11. Brogan

    Brogan XenForo Moderator Staff Member

    Edit the account_personal_details template and use xen:comment to comment out the relevant code.
     
  12. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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
     
  13. Brogan

    Brogan XenForo Moderator Staff Member

    You could do it with a query or manually editing the field in the ACP under the Personal Details tab for each member.
     
  14. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    I think I can find the info with a DB query but then would I just need to copy that table and replace the new one with it?
     
  15. Brogan

    Brogan XenForo Moderator Staff Member

    You would need to query the existing field and then insert into the new field, making sure to match the user IDs.
     
  16. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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?
     
  17. Brogan

    Brogan XenForo Moderator Staff Member

    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.
     
  18. Floyd R Turbo

    Floyd R Turbo Well-Known Member

    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....
     

Share This Page