We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    It might be easiest just to create a new table with two fields: userId and yourId. It sounds like using one of the user form fields may not work for you. It may not be worth subclassing the user object.

    Using an extended field for it is kind of a hassle to set up and I think it would allow the user to edit the field when editing the profile, though I’m not sure. I guess you could let them update the profile with a form in the front end and just not show that field.
      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
      • 28120
      • 380 Posts
      There seem to be a lot of separate posts about adding extra fields to user profiles.

      I think this topic should be finding its way on to the roadmap?
        • 26503
        • 620 Posts
        @Bob;

        now that I think about it, and I haven’t checked the docs yet - but I think I did this before, if you pass an extra field in the user signup form, doesn’t modx auto jack that into the user profile as an axtra field already? I suppose if this is the case and worse comes to worse, I could just pass a hidden field in the signup & make them add new users that way?


        also - in preparation of actually writing this thing & trying to get it to work, I’ve been running through this: http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution I can get it to work about 90%, everything seems to make sense, files are created, scripts run, the only thing that does not happen is I don’t get any results back from the database table - and no errors.... how can I troubleshoot this?

        @sparky:

        I’m down with that - I have another project coming up that has tons of user extras - another 20 fields at least that need to be searchable with a custom search plugin.

        How do we get that started?

        -sean
          *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

          Sean Kimball CLP, CLS.
          Technical Director / Sr. Developer | BigBlock Studios
          ._______________________________________________.
          Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
          27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
          phone/fax: 905-426-5525
          • 3749
          • 24,544 Posts
          Quote from: sean69 at Mar 25, 2011, 09:58 AM

          @Bob;

          now that I think about it, and I haven’t checked the docs yet - but I think I did this before, if you pass an extra field in the user signup form, doesn’t modx auto jack that into the user profile as an axtra field already? I suppose if this is the case and worse comes to worse, I could just pass a hidden field in the signup & make them add new users that way?


          also - in preparation of actually writing this thing & trying to get it to work, I’ve been running through this: http://rtfm.modx.com/display/revolution20/Developing+an+Extra+in+MODX+Revolution I can get it to work about 90%, everything seems to make sense, files are created, scripts run, the only thing that does not happen is I don’t get any results back from the database table - and no errors.... how can I troubleshoot this?

          @sparky:

          I’m down with that - I have another project coming up that has tons of user extras - another 20 fields at least that need to be searchable with a custom search plugin.

          How do we get that started?

          -sean
          On the extra field in the signup form: I just don’t know.

          On storing the info in a separate table, you might take a look at this also. It’s a little out of date (I’m rewritiing it this week), but it gives a slightly different approach: http://bobsguides.com/custom-db-tables.html. If you’re doing to be searching the extra fields, then you probably do want a custom table.

          On troubleshooting: Post the code that isn’t working.
            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
            • 26503
            • 620 Posts
            Hi Bob;

            Thanks - I will definitely check that article out - I’m sort of in the process of learning all the background stuff before I jump right in there and get myself into some odd kind of trouble~ smiley


            I just took a look into the extended field thing:


            Basically, to start using extended fields, all you have to do is add a form field to your Register and UpdateProfile forms. That’s it. The snippets will automatically then check for any fields in the POST that aren’t in the User table, and if found, store them as extended (custom) fields. They will then be expanded when using the Profile snippet. For example, a Register form that has this in it:

            Seems to indicate "Yes, it does", however - a custom table will definitely be the way to go for project 2.


            On troubleshooting, thanks for the offer, I did find the modx error log in the manager section useful and it pointed me to [in a roundabout way] the system variable for the snippet url being wrong [vhome vs. vhosts]

            It is working as advertised now [:)] so the next step for me is to reverse engineer it and figure out how to reapply that for my purposes.

            The one thing I am thinking ahead about and will probably have some questions[as I haven’t hit on any hints yet] - is that I am inserting a UUID in a custom table on the ’OnUserFormSave’ event in the manager context... [Random thought - should I just write a stored proc to do this and ignore modx completely???] - the new user or user we are editing, is that user id available to me at this point somehow, or am I going to have to get the last insert/update from the database?

            -thanks
            -sean

              *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

              Sean Kimball CLP, CLS.
              Technical Director / Sr. Developer | BigBlock Studios
              ._______________________________________________.
              Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
              27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
              phone/fax: 905-426-5525
              • 3749
              • 24,544 Posts
              (My 9,000th post -- I need to get a life. wink )

              The User ID will be available automatically in the plugin as $id.

              You could put the table in the MODx database and use PDO to access it. That would be much better than opening another database connection.
                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
                • 26503
                • 620 Posts
                hmmm... having some trouble now.

                I tried creating the new user table for the UUID’s following the tutorial pretty much exactly, changing only the path names, script & class etc. and a new database schema.... problem is that modx is not creating the database table, nor is it throwing any errors... [all the class files, etc are created, directories and such] not sure where to start troubleshooting this, maybe in my sql schema?

                <?xml version="1.0" encoding="UTF-8"?>
                
                	<model package="reselleruuid" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" phpdoc-package="reselleruuid" phpdoc-subpackage="model">
                		<object class="reselleruuid" table="reselleruuid" extends="xPDOSimpleObject">
                			<field key="id" dbtype="int" precision="10" phptype="integer" null="false" default="" index="pk" attributes="unsigned"  />
                			<field key="uid" dbtype="int" precision="10" phptype="integer" null="false" default="" />
                			<field key="uuid" dbtype="int" precision="12" phptype="string" null="false" default="000000000000" />
                			
                			<aggregate alias="UID" class="modUser" local="uid" foreign="id" cardinality="one" owner="foreign"/>
                		</object>
                	</model>
                


                thoughts?

                **UPDATE:

                well at least I’m getting this now:
                [2011-03-28 16:48:10] (ERROR @ /index.php) Could not get table name for class: Reselleruuid
                [2011-03-28 16:48:10] (ERROR @ /index.php) Reselleruuid::loadCollection() is not a valid static method.
                

                -sean
                  *** Not just websites, we also create signage, banners, print, trade show displays and more! ***

                  Sean Kimball CLP, CLS.
                  Technical Director / Sr. Developer | BigBlock Studios
                  ._______________________________________________.
                  Bigblock Studios http://www.bigblockstudios.ca Web site design & development.
                  27-1300 King Street East. Box 167 Oshawa, Ontario L1H8J4 Canada.
                  phone/fax: 905-426-5525
                  • 34193
                  • 330 Posts
                  I found when extending modUser I had to add
                  $manager->createObjectContainer(’className’);
                  to the end of the build script in order to create the table. This isn’t mentioned in the docs.
                    • 34193
                    • 330 Posts
                    Also this step
                    3.) Create (or edit) extension_packages in System Settings

                    Access the System settings found in the System menu of the manager, and search for: extension_packages.

                    If the key already exists, add

                    1
                    , extendeduser:{core_path}components/extendeduser/model/
                    Note the comma at the beginning of the Value.
                    If the key does not exists

                    Create a new system setting with name of extension_packages
                    Key of extension_packages
                    Fieldtype: Textfield
                    value
                    1
                    extendeduser:{core_path}components/extendeduser/model/

                    is now replaced with

                    [{"packageName":{"path":"/path/to/model/"}}]
                      • 34193
                      • 330 Posts
                      and third since you are extending xPDOSimpleObject

                      I don’t think you need

                      <field key="id" dbtype="int" precision="10" phptype="integer" null="false" default="" index="pk" attributes="unsigned" />

                      as this is assumed.

                      But I may be wrong on this one.