We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15136
    • 34 Posts
    Hey guys,

    Here's what I want to do. I'm about to add 5000 users. However each user should have more than just the regular user details. For example, height, weight, bio, record, among other things.

    However, I have 2 types of users, and these fields would only be for one user, so i'm leaning towards extended fields instead of just updating the database tables to allow for these extra fields.

    My question is, how is it that I can manually add users, assign them to a group, and fill out the extended fields without having to declare those fields each and every time?

    Should I just create another table to allow for this misc data and then create a customized page in the manager?

    I can accomplish this task, I'm just trying to think of the easiest, more robust solution that makes sense.


    Anyone have a good way to tackle this?
      2.2.4 Revolution
      • 22303 MODX Staff
      • 10,725 Posts
      Can't you insert those users with the extended fields defined, just with empty (or default) values?
        • 15136
        • 34 Posts
        sure, but i wouldn't want empty or default values, they would already have content associated with them.

          2.2.4 Revolution
          • 15136
          • 34 Posts
          Maybe my originally post wasn't so clear. I'd like to import an original batch, and then manually add afterwards.


          I think I've figured out my own personal solution. I'm going to just add a new table with a unique id for each entry as well as add another field to the users table with the same unique identifier. Then just spit out all the info on the users profile page.

          Then the information that I want the user to be able to update, I'll create an extended field for. If the extended field isn't blank, it'll output that, if it is blank it'll output the value in the new table.


          Although if the extended field is empty, I'm not sure of the logic to be used for figuring out how to pull in the data from the table.

          Pseudo code would be

          (If Extended field is empty){
          perhaps send parameter of empty field to snippet,
          Snippet would search DB table and match field with parameter passed and return that value
          }

          Slowly but surely!
            2.2.4 Revolution
            • 22303 MODX Staff
            • 10,725 Posts
            I would not recommend changing the structure of any of the core tables. You can add a custom table and use the primary key from the modUser (users) table as the foreign key back.
              • 3749
              • 24,544 Posts
              The problem is that your code needs a user object for a particular user who already has a profile in order to manipulate the extended fields, unless you're creating a new user and profile in your code.

              The code would depend on the Version of MODX you're using.


              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                Did I help you? Buy me a beer
                Get my Book: MODX:The Official Guide
                MODX info for everyone: http://bobsguides.com/modx.html
                My MODX Extras
                Bob's Guides is now hosted at A2 MODX Hosting