We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36875
    • 5 Posts
    I am using MODx Revolution 2.1.0-pl and the Login add-on. I am working on a site where users can create a profile with a lot of fields that are not in the database by default. I have added columns for these fields to the user_attributes table. However, when someone registers as a new user, all the extra fields end up in the column ’extended’. Maybe I should have understood that from the documentation (particularly http://rtfm.modx.com/display/ADDON/Login.Using+Custom+Fields) but I guess I didn’t read it carefully enough or maybe I just missed the point smiley

    Anyway, I am kind of unsure what to do now. I am thinking of two possibilities:

    1. Leave everything the way it is. Remove the new columns from the database (which are not used anyway). Problem is that visitors to the site need to be able to search through the accounts, with the new fields as search criteria. Since they’re all lumped together in the ’extended’ column, I don’t know if that is even possible. I think it probably is, since you can view the new fields when you use the Profile snippet from the Login add-on. But I don’t really understand how this works.

    2. Figure out a way to add the new fields in new database columns instead of the ’extended’ column. Not sure how to do that: change the schema.xml? But I read somewhere (I think, can’t find it now) that this would make it impossible to update MODx. So maybe that’s a bad idea.

    I hope I’ve explained my problem clearly. What do you think would be the best thing to do?

      • 1576
      • 24 Posts
      You can access your extended fields in the following way:

          $profile = $modx->user->getOne('Profile');
          $fields = $profile->get('extended');
      
          $field1 = $fields['field1'];
          $field2 = $fields['field2']; 


      Then you can assign $field1, $field2, etc., to a query, or whatever you like. The value of $field1 will be the value of the extended field.

      Hope that helps.
        • 36875
        • 5 Posts
        Thank you! I figured that out eventually and I am now going with option 1 (as described in my first post). I have not really come across any downsides to this approach yet, except that it’s very hard to read the extended field when you’re accessing the database directly, but that doesn’t really count.