We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22019
    • 390 Posts
    Extending modUser by using a custom table would get you both the above benefits, and is more ’extensible’ if you’ll pardon the pun.

    I have also shied away from extended fields for reports because it is a json object, but I think the principle is to select the row ’normally’ and then deserialise the column, rather than try to do it all in the SELECT statement (messy, as you’ve observed). To my old school eyes, it looks like a foreign key relationship defined and stored in a single column.
      Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
      • 22303 MODX Staff
      • 10,725 Posts
      Right, it was added as a simple and convenient way to store additional data on the user profile. It is not intended for critical custom profile data that needs to be searched and sorted on. This is a similar principal to Template Variables, except their primary intention is organization of the presentation layer, but definitely not for storing searchable/sortable data.
        • 28120
        • 380 Posts
        The road to hell is paved with good intentions smiley

        Personally I was just trying to get to the bottom of what extended fields offer. Now I understand them I know when is the time and place to use them.

        You’ve said Template Variables are definitely not for storing searchable/sortable data but I thought these were to be used for Tagging. They seem to work well for searching for me?

        Please don’t take questioning as criticism, I’m just trying to understand Revolution. So far I’m amazed by its power and flexibility and have already committed to using it for all site development and really appreciate the effort and thought you guys are putting into it.

        Template Variables seem powerful and understandable but personally I think security and form customization are probably equally powerful just not as understandable. For example there’s Lexicon Management and Form Customization (but only for Resources) and so I’m uncertain as to which one to use to change the label on Resource forms.
          • 34193
          • 330 Posts
          Quote from: sparkyhd at Mar 17, 2011, 09:41 AM

          Please don’t take questioning as criticism,

          Most of the guys here won’t many question and answer topics have been posted and most people are more than happy to answer question where they can it is why I feel it is such a great community. And helps many of us understand modx better.

          Quote from: sparkyhd at Mar 17, 2011, 09:41 AM

          For example there’s Lexicon Management and Form Customization (but only for Resources) and so I’m uncertain as to which one to use to change the label on Resource forms.

          My understanding here is as follows (but I may be wrong)
          Lexicon is a system wide, same for every user/resource

          Form Customization gives much greater control, even down to user groups and resource groups.

          So a blog entry might want a limited number of fields visable where as a full blown page might want more.

          An end user might only need to see a limited number of fields where as a developer might want all of them.

          Also if I remember correctly FC allows you to move fields around tabs IE bring a TV onto the main tab etc...
            • 17016
            • 138 Posts
            We want to add an extra fields to the User table for a personal "membership-number", which later should be verified automatically by comparing the values of a online-database located on an server in a different city than our webserver with the values of the membership-number typed in the field when registering.

            Is it recommend to use an extended field for this purpose or better to rename an already existing field like the fax-number? Or is there a third solution which should be preferred?

            Thanks in advance! Letti
              • 3749
              • 24,544 Posts
              It can be done either way, but it will be faster and easier if you use an existing field in the user profile.
                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
                • 17016
                • 138 Posts
                I was trying to let a plugin create the extended field "soccer" in a user-profile and set it to "1" by this code but it doesn´t work (whereas adding the user to the group "member" works). Does anybody have an idea what I did wrong? The plugin listens to "OnUserActivate".

                  $soccernew = '1';
                  $profile->set('soccer', $soccernew);
                  $profile->save();
                  $user->joinGroup('members');
                
                  • 3749
                  • 24,544 Posts
                  Quote from: Letti at Apr 15, 2011, 11:03 AM

                  I was trying to let a plugin create the extended field "soccer" in a user-profile and set it to "1" by this code but it doesn´t work (whereas adding the user to the group "member" works). Does anybody have an idea what I did wrong? The plugin listens to "OnUserActivate".

                    $soccernew = '1';
                    $profile->set('soccer', $soccernew);
                    $profile->save();
                    $user->joinGroup('members');
                  


                  I don’t think OnUseActivate ever fires in the current version except when invoked by an add-on like the Register snippet. Take a look at the ActivationEmail plugin to see how to catch activation if you’re not using the Register snippet. Also, be sure to get the profile before altering it:

                  $profile = $user->getOne('Profile');
                    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
                    • 17016
                    • 138 Posts
                    OK, with this code I was able to change for example the gender from female to male, but I was not able to add a new extension field which doesn´t exist before. It seems to be a difference if the variable exist before or if it is a new one. Do you know how to add a new extension field by a plugin like this?

                    Thanks a lot for your great help!

                    Letti
                      • 3749
                      • 24,544 Posts
                      Extended fields are stored as an array. You have to add one like this:

                      $fields=$profile->get('extended');
                      $fields['newFieldName']='something';
                      $profile->set('extended',$fields);
                      $profile->save();
                      
                        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