We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 13736
    • 345 Posts
    I need to setup a user profile system that can handle an unknown set of additional addresses. So for example one user (company) might have 3 address locations while another user might have 10 locations. How would I setup something like this so it is simple to add another location.

    Do I pre-create database tables with a really high maximum amount of locations per user or is there a good way to generate something on the fly and link it to the user. I figured this is similar to the way a system like Google Contacts allows you to add extra phone numbers, email, addresses, or whatever to a contact.
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Which version of MODx are you using?

      Evo has a table for users "web_user_settings" that would be useful for this; it has the fields "webuser" for the user ID, "setting_name" for the name of the field and "setting_value" for the value. So you could have a form with some Javascript to automatically add a new field, or a button to refresh the page with another field, and use this table to store these "settings", like "<id>", "address1", "<first address>", and "<id>", "address2", "<second address>" etc for as many addresses as necessary. To pull it out, you’d need a "WHERE `webuser` = <id> AND `setting_name` LIKE ’address%’ " to get all the addresses for a given user.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 13736
        • 345 Posts
        I’m actually looking at using Revo if possible.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          As far as I can tell, with Revo you can do anything you want, in just about any way you could imagine. I’m sure the Revo gurus can give some good advice on the most efficient way, though.
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org