We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44580
    • 189 Posts
    I have the following workflow:

    Potential customer fills out a quote request form on the front end. Confirmation emails are sent to the customer and the Site Admin. The form's content is also saved to a table in the database. The Site Admin contacts the potential customer and signs them up (hopefully).

    What I've done: Form is created (using Formit) and emails are being successfully sent. Data is being saved to a custom table in the database (using Formit2db). Using Migxdb, I have a CMP set up that displays the saved information. This is all working fine.

    What I would like to do: Once the Site Admin has signed up a new customer, he should be able to go to the CMP, select the new customer from the list of saved forms and click on an option that will automatically create a moduser record for the customer (based on the information already gathered), set a password, and then send a confirmation email to the new customer with the password. The new customer can then log into the site using Login.

    Beyond the fact that I will need a snippet to do the Migxdb -> Moduser stuff I really have no idea where to go next. I also have no idea how to create an option in the Migxdb CMP to initiate the process. Any help would be greatly appreciated.

    Robert.
      • 3749
      • 24,544 Posts
      It it's in a CMP, the usual way would be a button and JS that calls a processor when the button is clicked on. The modUser creation and email would be done in a processor.

      It might be simpler, though to just create a regular form on the CMP page that posts to a page with a snippet when "Submit" is clicked.

      Creating the user and emailing are both fairly simple. If the form fields are named correctly, you might be able to create the user like this:

      $fields = $_POST;
      $modx->runProcessor('user/create', $fields);
      


      For security, you'll probably want to sanitize the fields before calling the processor.
        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
        • 4172
        • 5,888 Posts
        you will need to create a new gridcontextmenu - item, like shown here:
        https://github.com/Bruno17/migxElementsManager/blob/master/core/components/migxelementsmanager/migxconfigs/grid/grid.config.inc.php#L62

        in a new file named
        core/components/{yourpackage}/migxconfigs/grid/grid.config.inc.php
        and a function like here:

        https://github.com/Bruno17/migxElementsManager/blob/master/core/components/migxelementsmanager/migxconfigs/grid/grid.config.inc.php#L142

        which points to a processor, defined with the line
        ,processaction: 'writetofiles' <- here the name of your processor-php-file

        then you can select that new contextmenu-item in the migx-configurator.

        and you will need a processor
        the example above for example would call that processor:
        https://github.com/Bruno17/migxElementsManager/blob/master/core/components/migxelementsmanager/processors/mgr/default/writetofiles.php

        which would need to be placed here:
        core/components/{yourpackage}/processors/mgr/default/{processaction}.php

        Then in that processor set all needed fields for user/create and like Bob allready suggested, call the user/create - processor with that fields correctly set

        $modx->runProcessor('user/create', $fields);



        if you would like to show your current exported MIGXdb - configuration and your xpdo-schema, I could post the needed steps and values exactly.
          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 44580
          • 189 Posts
          Many thanks Bruno, Bob. I will work my way through all your suggestions. Meanwhile, as per your kind offer Bruno, here is my schema and exported configuration:

          <?xml version="1.0" encoding="UTF-8"?>
          <model package="add" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
          	<object class="Quote" table="quote" extends="xPDOSimpleObject">
          		<field key="cost_per_hour" dbtype="smallint" precision="6" phptype="integer" null="true" />
          		<field key="num_families" dbtype="varchar" precision="10" phptype="string" null="true" />
          		<field key="day_of_week" dbtype="varchar" precision="15" phptype="string" null="true" />
          		<field key="time_of_day" dbtype="varchar" precision="20" phptype="string" null="true" />
          		<field key="first_name" dbtype="varchar" precision="30" phptype="string" null="true" />
          		<field key="last_name" dbtype="varchar" precision="30" phptype="string" null="true" />
          		<field key="address" dbtype="varchar" precision="40" phptype="string" null="true" />
          		<field key="suburb" dbtype="varchar" precision="30" phptype="string" null="true" />
          		<field key="city" dbtype="varchar" precision="15" phptype="string" null="true" />
          		<field key="state" dbtype="varchar" precision="3" phptype="string" null="true" />
          		<field key="postcode" dbtype="varchar" precision="4" phptype="string" null="true" />
          		<field key="phone_no" dbtype="varchar" precision="12" phptype="string" null="true" />
          		<field key="email" dbtype="varchar" precision="30" phptype="string" null="true" />
          		<field key="coach_id" dbtype="smallint" precision="6" phptype="integer" null="true" />
          	</object>
          </model>


          {
            "formtabs":[
              {
                "MIGX_id":3,
                "caption":"Quote",
                "print_before_tabs":"0",
                "fields":[
                  {
                    "MIGX_id":10,
                    "field":"cost_per_hour",
                    "caption":"Cost per Hour",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":1
                  },
                  {
                    "MIGX_id":11,
                    "field":"num_family",
                    "caption":"Number of Families",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":2
                  },
                  {
                    "MIGX_id":12,
                    "field":"day_of_week",
                    "caption":"Day",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":3
                  },
                  {
                    "MIGX_id":13,
                    "field":"time_of_day",
                    "caption":"Time",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":4
                  },
                  {
                    "MIGX_id":14,
                    "field":"first_name",
                    "caption":"First Name",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":5
                  },
                  {
                    "MIGX_id":15,
                    "field":"last_name",
                    "caption":"Last Name",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":6
                  },
                  {
                    "MIGX_id":16,
                    "field":"address",
                    "caption":"Address",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":7
                  },
                  {
                    "MIGX_id":17,
                    "field":"suburb",
                    "caption":"Suburb",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":8
                  },
                  {
                    "MIGX_id":18,
                    "field":"city",
                    "caption":"City",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":9
                  },
                  {
                    "MIGX_id":19,
                    "field":"state",
                    "caption":"State",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":10
                  },
                  {
                    "MIGX_id":20,
                    "field":"postcode",
                    "caption":"Postcode",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":11
                  },
                  {
                    "MIGX_id":21,
                    "field":"phone_no",
                    "caption":"Phone",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":12
                  },
                  {
                    "MIGX_id":22,
                    "field":"email",
                    "caption":"Email",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":13
                  },
                  {
                    "MIGX_id":23,
                    "field":"coach_id",
                    "caption":"Coach Id",
                    "description":"",
                    "description_is_code":"0",
                    "inputTV":"",
                    "inputTVtype":"",
                    "validation":"",
                    "configs":"",
                    "restrictive_condition":"",
                    "display":"",
                    "sourceFrom":"config",
                    "sources":"",
                    "inputOptionValues":"",
                    "default":"",
                    "pos":14
                  }
                ],
                "pos":1
              }
            ],
            "contextmenus":"update||remove",
            "actionbuttons":"",
            "columnbuttons":"update||remove",
            "filters":"",
            "extended":{
              "migx_add":"Add Quote",
              "disable_add_item":"",
              "formcaption":"Manage Quotes",
              "update_win_title":"Quotes",
              "win_id":"Quote",
              "maxRecords":"",
              "addNewItemAt":"bottom",
              "multiple_formtabs":"",
              "actionbuttonsperrow":4,
              "winbuttonslist":"cancel||done",
              "extrahandlers":"",
              "filtersperrow":4,
              "packageName":"add",
              "classname":"Quote",
              "task":"",
              "getlistsort":"",
              "getlistsortdir":"",
              "sortconfig":"",
              "gridpagesize":"",
              "use_custom_prefix":1,
              "prefix":"add_",
              "grid":"",
              "gridload_mode":1,
              "check_resid":1,
              "check_resid_TV":"",
              "join_alias":"",
              "has_jointable":"yes",
              "getlistwhere":"",
              "joins":"",
              "cmpmaincaption":"Quote",
              "cmptabcaption":"Manage quotes",
              "cmptabdescription":"Quotes",
              "cmptabcontroller":"",
              "winbuttons":"",
              "onsubmitsuccess":"",
              "submitparams":""
            },
            "columns":[
              {
                "MIGX_id":1,
                "header":"Cost",
                "dataIndex":"cost_per_hour",
                "width":3,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":2,
                "header":"Families",
                "dataIndex":"num_families",
                "width":6,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":3,
                "header":"Day",
                "dataIndex":"day_of_week",
                "width":10,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":4,
                "header":"Time",
                "dataIndex":"time_of_day",
                "width":15,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":5,
                "header":"First Name",
                "dataIndex":"first_name",
                "width":20,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":6,
                "header":"Last Name",
                "dataIndex":"last_name",
                "width":20,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":7,
                "header":"Address",
                "dataIndex":"address",
                "width":40,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":8,
                "header":"Suburb",
                "dataIndex":"suburb",
                "width":15,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":9,
                "header":"City",
                "dataIndex":"city",
                "width":12,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":10,
                "header":"State",
                "dataIndex":"state",
                "width":4,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":11,
                "header":"Postcode",
                "dataIndex":"postcode",
                "width":6,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":12,
                "header":"Phone no.",
                "dataIndex":"phone_no",
                "width":10,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":13,
                "header":"Email",
                "dataIndex":"email",
                "width":25,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":14,
                "header":"Coach ID",
                "dataIndex":"coach_id",
                "width":5,
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              },
              {
                "MIGX_id":15,
                "header":"",
                "dataIndex":"id",
                "width":"",
                "sortable":"false",
                "show_in_grid":1,
                "renderer":"",
                "clickaction":"",
                "selectorconfig":"",
                "renderchunktpl":"",
                "renderoptions":""
              }
            ]
          }


          (I've just realised that I've created a form that I don't need - all I'll be doing is displaying the records in a grid and either deleting or migrating them - I won't be adding or editing them.)

          Not all the fields in the quote will be used to create the Moduser record. first_name + last_name will map to fullname as well as username. The rest of the mapping is fairly obvious. Eventually, the extra fields will be stored in other external tables, but that's an issue for another day...
            • 4172
            • 5,888 Posts
            this should work:

            MIGX - configuration:

            {
              "formtabs":[
                {
                  "MIGX_id":27,
                  "caption":"Quote",
                  "print_before_tabs":"0",
                  "fields":[
                    {
                      "MIGX_id":105,
                      "field":"cost_per_hour",
                      "caption":"Cost per Hour",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":1
                    },
                    {
                      "MIGX_id":106,
                      "field":"num_family",
                      "caption":"Number of Families",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":2
                    },
                    {
                      "MIGX_id":107,
                      "field":"day_of_week",
                      "caption":"Day",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":3
                    },
                    {
                      "MIGX_id":108,
                      "field":"time_of_day",
                      "caption":"Time",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":4
                    },
                    {
                      "MIGX_id":109,
                      "field":"first_name",
                      "caption":"First Name",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":5
                    },
                    {
                      "MIGX_id":110,
                      "field":"last_name",
                      "caption":"Last Name",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":6
                    },
                    {
                      "MIGX_id":111,
                      "field":"address",
                      "caption":"Address",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":7
                    },
                    {
                      "MIGX_id":112,
                      "field":"suburb",
                      "caption":"Suburb",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":8
                    },
                    {
                      "MIGX_id":113,
                      "field":"city",
                      "caption":"City",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":9
                    },
                    {
                      "MIGX_id":114,
                      "field":"state",
                      "caption":"State",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":10
                    },
                    {
                      "MIGX_id":115,
                      "field":"postcode",
                      "caption":"Postcode",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":11
                    },
                    {
                      "MIGX_id":116,
                      "field":"phone_no",
                      "caption":"Phone",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":12
                    },
                    {
                      "MIGX_id":117,
                      "field":"email",
                      "caption":"Email",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":13
                    },
                    {
                      "MIGX_id":118,
                      "field":"coach_id",
                      "caption":"Coach Id",
                      "description":"",
                      "description_is_code":"0",
                      "inputTV":"",
                      "inputTVtype":"",
                      "validation":"",
                      "configs":"",
                      "restrictive_condition":"",
                      "display":"",
                      "sourceFrom":"config",
                      "sources":"",
                      "inputOptionValues":"",
                      "default":"",
                      "pos":14
                    }
                  ],
                  "pos":1
                }
              ],
              "contextmenus":"remove||createUser",
              "actionbuttons":"addItem",
              "columnbuttons":"remove||createUser",
              "filters":"",
              "extended":{
                "migx_add":"Add Quote",
                "disable_add_item":"",
                "formcaption":"Manage Quotes",
                "update_win_title":"Quotes",
                "win_id":"Quote",
                "maxRecords":"",
                "addNewItemAt":"bottom",
                "multiple_formtabs":"",
                "actionbuttonsperrow":4,
                "winbuttonslist":"",
                "extrahandlers":"",
                "filtersperrow":4,
                "packageName":"add",
                "classname":"Quote",
                "task":"",
                "getlistsort":"id",
                "getlistsortdir":"DESC",
                "sortconfig":"",
                "gridpagesize":"",
                "use_custom_prefix":1,
                "prefix":"add_",
                "grid":"",
                "gridload_mode":1,
                "check_resid":1,
                "check_resid_TV":"",
                "join_alias":"",
                "has_jointable":"yes",
                "getlistwhere":"",
                "joins":"",
                "cmpmaincaption":"Quote",
                "cmptabcaption":"Manage quotes",
                "cmptabdescription":"Quotes",
                "cmptabcontroller":"",
                "winbuttons":"",
                "onsubmitsuccess":"",
                "submitparams":""
              },
              "columns":[
                {
                  "MIGX_id":5,
                  "header":"First Name",
                  "dataIndex":"first_name",
                  "width":20,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":6,
                  "header":"Last Name",
                  "dataIndex":"last_name",
                  "width":60,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"this.renderRowActions",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":7,
                  "header":"Address",
                  "dataIndex":"address",
                  "width":40,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":9,
                  "header":"City",
                  "dataIndex":"city",
                  "width":12,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":10,
                  "header":"State",
                  "dataIndex":"state",
                  "width":4,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":11,
                  "header":"Postcode",
                  "dataIndex":"postcode",
                  "width":6,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":13,
                  "header":"Email",
                  "dataIndex":"email",
                  "width":25,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":15,
                  "header":"",
                  "dataIndex":"id",
                  "width":"",
                  "sortable":"false",
                  "show_in_grid":"0",
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                },
                {
                  "MIGX_id":16,
                  "header":"User ID",
                  "dataIndex":"user_id",
                  "width":20,
                  "sortable":"false",
                  "show_in_grid":1,
                  "renderer":"",
                  "clickaction":"",
                  "selectorconfig":"",
                  "renderchunktpl":"",
                  "renderoptions":""
                }
              ]
            }
            


            schema - added a field user_id for the new created user

            <?xml version="1.0" encoding="UTF-8"?>
            <model package="add" baseClass="xPDOObject" platform="mysql" defaultEngine="MyISAM" version="1.1">
                <object class="Quote" table="quote" extends="xPDOSimpleObject">
                    <field key="cost_per_hour" dbtype="smallint" precision="6" phptype="integer" null="true" />
                    <field key="num_families" dbtype="varchar" precision="10" phptype="string" null="true" />
                    <field key="day_of_week" dbtype="varchar" precision="15" phptype="string" null="true" />
                    <field key="time_of_day" dbtype="varchar" precision="20" phptype="string" null="true" />
                    <field key="first_name" dbtype="varchar" precision="30" phptype="string" null="true" />
                    <field key="last_name" dbtype="varchar" precision="30" phptype="string" null="true" />
                    <field key="address" dbtype="varchar" precision="40" phptype="string" null="true" />
                    <field key="suburb" dbtype="varchar" precision="30" phptype="string" null="true" />
                    <field key="city" dbtype="varchar" precision="15" phptype="string" null="true" />
                    <field key="state" dbtype="varchar" precision="3" phptype="string" null="true" />
                    <field key="postcode" dbtype="varchar" precision="4" phptype="string" null="true" />
                    <field key="phone_no" dbtype="varchar" precision="12" phptype="string" null="true" />
                    <field key="email" dbtype="varchar" precision="30" phptype="string" null="true" />
                    <field key="coach_id" dbtype="smallint" precision="6" phptype="integer" null="true" />
                    <field key="user_id" dbtype="int" precision="10" phptype="integer" null="true" />
                </object>
            


            core/components/add/migxconfigs/grid/grid.config.inc.php:
            <?php
            
            $gridcontextmenus['createUser']['code']="
            m.push({
              className : 'createUser',
              text: 'Create User',
              handler: 'this.createUser'
            });
            m.push('-');
            ";
            $gridcontextmenus['createUser']['handler'] = 'this.createUser';
            $gridfunctions['this.createUser'] = "
            createUser: function() {
              MODx.Ajax.request({
                url: this.config.url
                ,params: {
                  action: 'mgr/migxdb/process'
                  ,processaction: 'createuser'
                  ,object_id: this.menu.record.id
                  ,configs: this.config.configs
                  ,resource_id: this.config.resource_id
                  ,co_id: '[[+config.connected_object_id]]'
                  ,reqConfigs: '[[+config.req_configs]]'
                }
                ,listeners: {
                'success': {fn:this.refresh,scope:this}
                }
              });
            }
            ";
            


            core/components/add/processors/mgr/default/createuser.php

            <?php
            
            $config = $modx->migx->customconfigs;
            $prefix = isset($config['prefix']) && !empty($config['prefix']) ? $config['prefix'] : null;
            $errormsg = '';
            if (isset($config['use_custom_prefix']) && !empty($config['use_custom_prefix'])) {
                $prefix = isset($config['prefix']) ? $config['prefix'] : '';
            }
            $packageName = $config['packageName'];
            $packagepath = $modx->getOption('core_path') . 'components/' . $packageName . '/';
            $modelpath = $packagepath . 'model/';
            $is_container = $modx->getOption('is_container', $config, false);
            if (is_dir($modelpath)) {
                $modx->addPackage($packageName, $modelpath, $prefix);
            }
            $configs = $modx->getOption('configs', $scriptProperties, '');
            $object_id = $modx->getOption('object_id', $scriptProperties, '');
            $classname = $modx->getOption('classname', $config, '');
            
            //get the current selected object
            
            if ($object = $modx->getObject($classname, $object_id)) {
                $data = array();
                $data['active'] = true;
                //$data['specifiedpassword'] = $row['password'];
                //$data['confirmpassword'] = $row['password'];
                $data['passwordgenmethod'] = 'g';
                $data['passwordnotifymethod'] = 'e';
                $data['email'] = $object->get('email');
            
                $data['username'] = strtolower($object->get('first_name')). strtolower($object->get('last_name')).$object->get('id');//unique username
                $data['fullname'] = $object->get('first_name') . ' ' . $object->get('last_name');
                $response = $modx->runProcessor('security/user/create', $data);
                
                if ($newuser = $response->getObject()){
                    $object->set('user_id',$modx->getOption('id',$newuser));
                    $object->save();
                }
            
            }
            
            return $modx->error->success();
            
            



              -------------------------------

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 44580
              • 189 Posts
              Bruno, you're a marvel! That works perfectly! Thank you so much - I would never have worked this out for myself. I'm off to buy you a beer.

              Robert.
                • 4172
                • 5,888 Posts
                Robert, I'm glad, that this does work for you.
                Thanks for the beer!
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 44580
                  • 189 Posts
                  A minor follow-up.

                  In createuser.php, the line:
                  $data['passwordnotifymethod'] = 'e';
                  seems to use the signupemail_message key for the email content, but I want to use the websignupemail_message key content instead. I cannot find any documentation on what this should be changed to. Any ideas?
                    • 4172
                    • 5,888 Posts
                    not sure, if this will work, but you can try to add this line into the createuser - processor, just before calling the security/user/create - processor:

                        $modx->setOption('signupemail_message',$modx->getOption('websignupemail_message'));
                        $response = $modx->runProcessor('security/user/create', $data);
                      -------------------------------

                      you can buy me a beer, if you like MIGX

                      http://webcmsolutions.de/migx.html

                      Thanks!
                      • 44580
                      • 189 Posts
                      Thanks Bruno but no, it made no difference. Obviously, I could edit the signupemail_message, but surely there is a way to invoke the websignupemail_message, otherwise why bother having it there?