We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 38783
    • 571 Posts
    I have been using Bob Ray's very useful extra ClassExtender to create some additional user fields in a community website I am working on.

    https://bobsguides.com/classextender-class.html

    When you first run ClassExtender you edit the following chunks and then run the 'Extend modUser' snippet.

    • MyExtUserSchema
    • MyExtraUserFields

    This process creates the 'ext_user_data' table into which all of your specified fields are added.

    My (very simplistic) understanding is that the 'MyExtUserSchema' chunk is responsible for the table and field creation in the MODX database and the 'MyExtraUserFields' chunk creates the fields in your User admin area. I know it does some other magic.

    If you subsequently need to add more fields to the table it is necessary to add the fields directly to the 'ext_user_data' table using either the command line or something like phpMyAdmin as 'Extend modUser' will not alter an existing 'ext_user_data' table.

    So, after a rather long introduction, my actual question is:

    When adding additional fields after the initial run of 'Extend modUser', if I add my fields directly into my 'ext_user_data' table and then run the 'Extend modUser' again do I need to add those additional fields to the 'MyExtUserSchema' chunk, or is it sufficient add them only to the 'MyExtraUserFields' chunk.

    MODX: 2.7.1
    PHP: 7.2.13
    ClassExtender: 2.1.0pl

    This question has been answered by BobRay. See the first response.

      If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

      email: [email protected] | website: https://andytough.com
    • discuss.answer
      • 3749
      • 24,544 Posts
      Have you tried adding them to the schema first, then viewing the the Extend modUser resource and submitting the form?

      I'm not sure if it will add the fields to the DB or not (I think it will), but it should update the class and map files.
        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
        • 38783
        • 571 Posts
        Hi Bob

        It doesn't seem to add fields to the db when run a second time. So I have been adding them with phpMyAdmin before running.

        However your comment but it should update the class and map files suggests that just adding the fields via phpMyAdmin is not enough and that 'MyExtUserSchema' does do some important additional work.

        I will carry on with my current procedure of adding fields with phpMyAdmin, and updating both MyExtUserSchema and MyExtraUserFields before viewing the Extend modUser resource and submitting the form.

        I was just being lazy, thinking I might not have to MyExtraUserFields if I'd already created the fields manually!

        Thank for your help. Andy
          If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

          email: [email protected] | website: https://andytough.com
          • 3749
          • 24,544 Posts
          The schema is completely ignored at run time, *but* it is used to generate the class and map files. There is a class file for your class. Without either re-processing the schema or adding the new fields manually to the class file, that class won't have the class variables for any extra fields. I think the map file also refers to the fields, but I haven't looked at one lately.

          Even if you changed the schema and re-submitted the form, double check to make sure the class file refers to the new fields.
            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
            • 38783
            • 571 Posts
            Will do, thanks Bob
              If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

              email: [email protected] | website: https://andytough.com