On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Hi there!

    I'm using the PeopleGroup-snippet which gets provided with the Peoples-Package (latest version).

    To list all users of a specified user-group works well by using this call:

    [[PeopleGroup? &limit=`0` &usergroup=`Testgroup` &userTpl=`usersList` &toPlaceholder=`users` &getProfile=`1` &getExtended=`1` ]] 
    <ul>[[+users]]</ul>


    Now I'm trying to only show the users that are already activated. Right now the list shows every registered user if activated or not.The registration-confirmation will be done by the admin/customer, so there might be a delay until the user really gets activated.

    It's not that useful to see the users that are currently not activated in the list. Those are linked to a user-profile site, and by choosing one of the non-activated users I see a message "User not found"...but the values of the input-fields that are used during registration (firstName, lastName, userName, email) are displayed...but if my own user has entered some values in additional input-fields that can be used by doing an UpdateProfile get displayed for this non-activated user!?

    So when I could "filter" those non-acitvated users off the list this issue won't happen...

    • I don't think there's an easy way to do it since the user's active status is not contained in any of the user group tables. If the 'active' placeholder is set, and I think it is, you might be able to hide inactive users with an output modifier or the If snippet, but the totals would be off.

        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
      • and hello again!

        I tried to use the [[+active]]-placeholder already within my usersList-template/chunk:

        <li class="[[+cls]]">
        <a [[+user:is=`[[+id]]`:then=`class="active"`]] title="[[++cultureKey:is=`de`:then=`Benutzerkonto von [[+user]] anschauen`:else=`View account of [[+user]]`]]" href="[[++cultureKey:is=`de`:then=`[[~241]]`:else=`[[~242]]`]]?user=[[+id]]">[[+firstName]] [[+lastName]]</a> [b][[+active]][/b]
        </li>


        Then I get a "1" stated behind each users first- and lastName...because I think it checks for my own profile, the logged in one, which is actived for sure smiley

        As I (thought I) "know" from several researches in this forum I thought this could help:

        [[*active]] - no output
        [[~active]] - no output
        [[~[[+active]]]] - site root?!
        [[~[[*active]]]] - no putput

        But I'm still not getting when to use what, always try'n'error...

        I did check the related snippet too, but I couldn't find a way on how to filter for the active users.

        I think I have to edit the PeopleGroup-snippet to my needs.

        /* get users */
        $c = $modx->newQuery($userClass);
        $c->innerJoin('modUserGroupMember','UserGroupMembers');
        $c->innerJoin('modUserGroupRole','UserGroupRole','UserGroupMembers.role = UserGroupRole.id');
        $c->where(array(
            'UserGroupMembers.user_group' => $usergroup->get('id'),
        $total = $modx->getCount($userClass,$c);
        $c->select($modx->getSelectColumns($userClass,$userClass));
        $c->select(array(
            'UserGroupRole.name AS role',
            'UserGroupRole.id AS role_id',
        ));
        ));


        And I think the "where(array" (line 5) could be responsible for that...or the "select(arry" (line 9)? But my researches didn't help me so far...again.

        EDIT: I also wanted to add another field to the usersList like that:

        <li class="[[+cls]]">
        <a [[+user:is=`[[+id]]`:then=`class="active"`]] title="[[++cultureKey:is=`de`:then=`Benutzerkonto von [[+user]] anschauen`:else=`View account of [[+user]]`]]" href="[[++cultureKey:is=`de`:then=`[[~241]]`:else=`[[~242]]`]]?user=[[+id]]">[[+firstName]] [[+lastName]]</a> [b][[+start]][/b]
        </li>


        [[+start]] holds a year that gets chosen by updating the profile via a select-box. But if I implement the placeholder I'm getting the correct value for those users who have entered a value to this field already, but for any other user who hasn't entered a value yet the value of the actual chosen user gets displayed for them...hard to explain sad

        User 1 - no value
        User 2 - 2007
        User 3 - 2008

        Being on the profile of User 1:

        User 1 - no value
        User 2 - 2007 - correct value
        User 3 - 2008 - correct value

        Being on the profile of User 2:

        User 1 - 2007 - value from User 2, should be empty
        User 2 - 2007 - correct value
        User 3 - 2008 - correct value

        Being on the profile of User 3:

        User 1 - 2008 - value from User 3, should be empty
        User 2 - 2007 - correct value
        User 3 - 2008 - correct value

        [ed. note: profilneurotiker last edited this post 5 years, 6 months ago.]
        • You can't have the total and select statements inside your where array.

          I was looking at the PeopleGroups snippet rather than PeopleGroup.

          Here's my wild guess at what you want:

          /* get users */
          $c = $modx->newQuery($userClass);
          $c->innerJoin('modUserGroupMember','UserGroupMembers');
          $c->innerJoin('modUserGroupRole','UserGroupRole','UserGroupMembers.role = UserGroupRole.id');
          $c->where(array(
              'UserGroupMembers.user_group' => $usergroup->get('id'),
          ));
          $c->andCondition(array($userClass . '.' 'active' => '1'));  // this is the only thing added
          $total = $modx->getCount($userClass,$c);


          If that doesn't work, try this:

              $c->andCondition(array('modUser.active' => '1'));
          


          If neither works, try this line:

              $c->andCondition(array('modUser.active' => 1));
          


          Let me know if any of that works. The first one would be the preferred method.

          Adding an &activeOnly property should be easy if it works.

          A couple more to try:

          $c->andCondition(array('active' => '1'));
          $c->andCondition(array('active' => 1));
            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
          • Great...the second one seems to be correct:

            $c->andCondition(array('modUser.active' => '1'));


            I de-activated my own user and checked the usersList and now my account doesn't appear in the list like I wanted it to be!


            I was thinking about another way by not adding the user to a specified usergroup on registration, but on activation. As I'm using your ActivationEmail-Plugin I think it might be not too hard to do this...but as your suggestion is working I'm going to use that!


            Now I realized that I need to add such a statement to the "UserSearchForm"-snippet from the ClassExtender-Package. Because when I do a search with a value this non-activated user has somewhere in the DB-table, the search-result shows this non-activated user. I'm also able to view the user-profile-site.

            So maybe I should really try the way I mentioned before; no usergroup on registration but on activation, and get the user off the usergroup on deactivation. Gonna try this...
            • seems to be working by adding this to the ActivationEmail-Plugin:

              $dbUser->joinGroup('NameOfUsergroup','Member');}


              now I'd need to look how to de-join a user off a group on deactivation...

              But this isn't related to the GetExtUsers-snippet that gets run by the UserSearchForm-snippet. This one looks for the ext_users_data DB-table and is not related to the usergroup I think.
              • now I'd need to look how to de-join a user off a group on deactivation...

                This should be

                $dbUser->leaveGroup('NameOfUsergroup','Member');}


                but I got an error somewhere...need to do some more tests as the ActivationEmail-Plugin is not working like expected anymore...by implementing those lines to the /* activation */- and the /* deactivation */-part in the ActivationEmail-Plugin the activation in the edit-user-panel doesn't work anymore and the mails don't get send. So I made something wrong, gonna do further tests later.
                • It's me again...

                  So now I'm testing to use the GetExtUser-snippet instead of the PeopleGroup-snippet, because I need to display some value that's holded in the ext_user_data-DB-table. By using the PeopleGroup-snippet there went something wrong, it seems by using the GetExtUser-snippet it's correct.

                  But now I wanted to use the where-property like this:

                  [[!GetExtUsers?
                      &where=`{"firstName:=":"Marc","User.active:="1"}`
                      &extUserRowTpl=`myextUserRowTpl`
                  ]]


                  But this shows every user, not regarding the first where-case for the value of "firstName".

                  I also tried this:

                  [[!GetExtUsers?
                      &where=`{"User.active:="1"}`
                      &extUserRowTpl=`myextUserRowTpl`
                  ]]


                  but I'm also getting all users listed like I'd call the GetExtUsers-snippet without the where-property?

                  EDIT:

                  By using this:

                  [[!GetExtUsers?
                      &where=`{"firstName:=":"Marc"}`
                      &extUserRowTpl=`myextUserRowTpl`
                  ]]


                  it's working like expected; but adding "User.active:="1" to the where-property shows all users, although there is one user that is de-activated in the user-panel of the MODx-Backend.

                  I also added the [[+active]] placeholder to the myextUserRowTpl-chunk, and every user got a 1. This one de-activated user should have a 0 saved as value? [ed. note: profilneurotiker last edited this post 5 years, 6 months ago.]
                  • Ah, I think I got it...I changed this

                    $c->where($where);

                    to that

                    $c->where(array('User.active' => '1'));

                    EDIT:

                    I realized my solution didn't work correct for another resource I used the UserSearchForm-snippet, in which the GetExtUsers-snippet gets called to; instead I use this, which seems to be working:

                    $c->where($where);
                    $c->where(array('User.active' => '1')); [ed. note: profilneurotiker last edited this post 5 years, 6 months ago.]
                    • I think

                      &where=`{"firstName:=":"Marc","User.active:=":"1"}`


                      or

                      &where=`{"firstName":"Marc","User.active":"1"}`


                      should work, too
                      but not

                      "User.active:="1"


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

                        you can buy me a beer, if you like MIGX

                        http://webcmsolutions.de/migx.html

                        Thanks!