We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44195
    • 293 Posts
    I've just started playing around with Migxdb. (love you quickly you can get things working)

    How would I create a CMP that lists user details for users only within a certain user group?

    I have successfully listed usernames from modUser (I put modUser in the classname field under the migxDB-settings tab) but I also need to join Profile to get the other user values I'm guessing and then limit it to only a specific user group.

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

      I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
      Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
      • 4172
      • 5,888 Posts
      a simple setup to list only users of a given usergroup in the grid:

      {
        "formtabs":"",
        "contextmenus":"",
        "actionbuttons":"",
        "columnbuttons":"",
        "filters":"",
        "extended":{
          "migx_add":"",
          "disable_add_item":"",
          "add_items_directly":"",
          "formcaption":"",
          "update_win_title":"",
          "win_id":"usertest",
          "maxRecords":"",
          "addNewItemAt":"bottom",
          "multiple_formtabs":"",
          "multiple_formtabs_label":"",
          "multiple_formtabs_field":"",
          "multiple_formtabs_optionstext":"",
          "multiple_formtabs_optionsvalue":"",
          "actionbuttonsperrow":4,
          "winbuttonslist":"",
          "extrahandlers":"",
          "filtersperrow":4,
          "packageName":"",
          "classname":"modUser",
          "task":"",
          "getlistsort":"",
          "getlistsortdir":"",
          "sortconfig":"",
          "gridpagesize":"",
          "use_custom_prefix":"0",
          "prefix":"",
          "grid":"",
          "gridload_mode":1,
          "check_resid":1,
          "check_resid_TV":"",
          "join_alias":"",
          "has_jointable":"yes",
          "getlistwhere":{
            "UserGroup.user_group":5
          },
          "joins":[
            {
              "alias":"Profile"
            },
            {
              "alias":"UserGroup",
              "classname":"modUserGroupMember",
              "on":"UserGroup.member=modUser.id"
            }
          ],
          "hooksnippets":"",
          "cmpmaincaption":"User Manager",
          "cmptabcaption":"Users",
          "cmptabdescription":"Manage Users here",
          "cmptabcontroller":"",
          "winbuttons":"",
          "onsubmitsuccess":"",
          "submitparams":""
        },
        "columns":[
          {
            "MIGX_id":1,
            "header":"ID",
            "dataIndex":"id",
            "width":10,
            "sortable":true,
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          },
          {
            "MIGX_id":2,
            "header":"Username",
            "dataIndex":"username",
            "width":30,
            "sortable":true,
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          },
          {
            "MIGX_id":3,
            "header":"Fullname",
            "dataIndex":"Profile_fullname",
            "width":30,
            "sortable":"false",
            "show_in_grid":1,
            "renderer":"",
            "clickaction":"",
            "selectorconfig":"",
            "renderchunktpl":"",
            "renderoptions":"",
            "editor":""
          }
        ]
      }
      


      this is the where:
      {"UserGroup.user_group":5}
      

      change the id of the user_group

      this the joins:
      [
            {
              "alias":"Profile"
            },
            {
              "alias":"UserGroup",
              "classname":"modUserGroupMember",
              "on":"UserGroup.member=modUser.id"
            }
          ]
      


      you can get the fields of Profile with the prefix 'Profile_'

      example:
            "dataIndex":"Profile_fullname",


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

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 44195
        • 293 Posts
        Too easy!
        Thanks Bruno, that's perfect.
          I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
          Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
          • 44195
          • 293 Posts
          Is there an easy way to have the "export view" option only output the columns I have in my grid?
          And also only export that specific user group?

          I don't want superuser accounts to appear in the .csv and only require about 8 fields for the other users.
            I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
            Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com
          • discuss.answer
            • 4172
            • 5,888 Posts
            with this additions to the export.php
            https://github.com/Bruno17/MIGX/commit/e3679fd9e3dfb5ab2bc47fa12e0e3dadcc0c19a9

            this respects the where - config now and you can have a hooksnippet to add custom-configs

            in hooksnippets have:

            {"getcustomconfigs":"users_getexportfields"}
            


            then have a snippet 'users_getexportfields' with:

            $processor = $modx->getOption('processor',$scriptProperties,'');
            
            switch($processor){
            case 'export':
                $customconfigs = '{"exportfields":{"username":"Username","Profile_fullname":"Fullname"}}';
                return $customconfigs;
                break;
            }
            
            return;
            


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

              you can buy me a beer, if you like MIGX

              http://webcmsolutions.de/migx.html

              Thanks!
              • 44195
              • 293 Posts
              Works beautifully.

              You're a legend, Bruno!
                I'm lead developer at Digital Penguin Creative Studio in Hong Kong. https://www.digitalpenguin.hk
                Check out the MODX tutorial series on my blog at https://www.hkwebdeveloper.com