We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 49659
    • 86 Posts
    I have extended my users via Bob Ray's ClassExtender. I'm now trying to list all users via the following chunk:

    [[!GetExtUsers?
        &sortby=`lastName`
        &sortDir=`ASC`
        &extUserOuterTpl=`ExtUserOuterTplCustom`
        &extUserInnerTpl=`ExtUserInnerTplCustom` 
        &extUserRowTpl=`ExtUserRowTplCustom`
    ]]


    The 'GetExtUsers' snippet is listing the users as defined in a chunk I've named 'ExtUserRowTplCustom':

    <ul class="ext-user-row">
    
        <li class="ext-user-field">
            User ID: [[+id]]
        </li>
        <li class="ext-user-field">
            <a href="[[~73]]?userid=[[+id]]">View Profile</a>
        </li>
        <li class="ext-user-field">
            Username: [[+username]]
        </li>
        <li class="ext-user-field">
            email: [[+email]]
        </li>
        <li class="ext-user-field">
            First Name: [[+firstName]]
        </li>
        <li class="ext-user-field">
            Last Name: [[+lastName]]
        </li>
        <li class="ext-user-field">
            Full Name: [[+fullname]]
        </li>
        <li class="ext-user-field">
            Preferred Role: [[+prefRole]]
        </li>
        <li class="ext-user-field">
            Last Payment Date: [[+lastPymtDate:strtotime:date=`%b %e, %Y`]]
        </li>
        <li class="ext-user-field">
            Membership Expiration Date: [[+memberExpireDate:strtotime:date=`%b %e, %Y`]]
        </li>
        <li class="ext-user-field">
            Active: [[+active]]
        </li>
        <li class="ext-user-field">
            Group membership:
            <ul>
            [[PeopleGroups? &user=`[[+id]]` &limit=`0`]]
            </ul>
        </li>
    </ul>
    


    I have eight test users. This code lists all the user values correctly EXCEPT for [[+id]].

    The user id is usually correct, but three of the eight users are showing an incorrect id number. For example, a user with id=4 might display id=55, and the user with an id=55 might display id=57.

    By the way, the list is being generated in IE, and I'm using Firefox for Manager, so there is no authentication cross-talk that might be happening.

    Any ideas on what the issue is, and/or how to trouble-shoot this?

    Thanks in advance,

    Karl Forsyth
      • 3749
      • 24,544 Posts
      It could be a bug, but there might be some confusion about which ID is involved. The ext_user_data table has an 'id' field, but it doesn't hold the user's actual MODX ID (which is in the 'id' field in the modx_users table). In the ext_user_data table, the user's actual MODX ID is in the userdata_id field. That said, getExtUser should set both the 'id' placeholder and the 'userdata_id' placeholder to the user's actual MODX ID. If that's not happening, it's probably a bug.

      You might try using both placeholders and see if they match.

      I'm sure the numbers you're getting aren't random. It's remotely possible (though I think very unlikely) that some other process is interfering. Are any of the numbers you're getting the ID of the Resource containing the getExtUser's tag or a resource that's being displayed by a getResources call on the same page?

        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
        • 49659
        • 86 Posts
        The 'id' and 'userdata_id' fields were out of sync in the 'ext_user_data' table.

        I'll just use the 'userdata_id' field in the report, which is the consistently correct value.

        Thanks,

        Karl Forsyth
          • 3749
          • 24,544 Posts
          The 'id' and 'userdata_id' fields often hold the same data since both reflect the order of creation of the users. When they are the same, though, it's actually a coincidence. The 'id' field in that table is actually an arbitrary number. It's the autoincrement ID assigned to that record by MySQL. Once you start deleting and recreating users, the two will often get out of sync.

          You can count on the userdata_id to be the user's actual MODX ID, though.

            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
            • 3749
            • 24,544 Posts
            I should add that CE should not be assigning the 'id' field of the ext_user_data table to a placeholder at all. Looking at the code, I can't see how that would happen.

            Any 'id' placeholder should be set to the user's MODX ID. I'll have to see if I can duplicate the issue.
              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