We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 6720
    • 6 Posts
    I’ve found the database grin checked my user tables modx_manager_users and modx_web_users. Both sets of users start at 1 and go up. So no negative id’s.

    I’m back to the code:
    'createdBy' => $userid ,


    It will only work for me that way. It only creates a createdby entry if the user is a webuser logged in via the front end. But when an entry is created the manager interface shows the user name of the equivilent manager user. Just to be clear if I use Ditto to look at these docs the user name shown in the [+author+] field is the manager users name from the modx_manager_users table.

    To test further I created a new web user, logged in, created a new document. It shows up as being created by my manager user who has an id=5. In the modx_web_users table the new web user has an id of........5!!!

    So I guess a workaround here is to create a web user for each manager user that needs to use newspublisher (for blogging) and make sure I match up the IDs. It will work but of course the slight pain is getting users to log into the front end for blogging and the back end for anthing else. Whilst I’m sure that this solution works in the sense of ’well, maybe thats how it should work...front to front back to back etc....’ I’m not sure I understand why a front end user would create documents as if they were back end users.

    I hope I’ve got the terminology right here, wouldn’t want to offend anyone, but this split of front and back is how I see things.

    If you have any other suggestions I could test I’d be happy to try if only from the viewpoint of understanding better.

    Thanks for your help (and patience) so far BobRay.
      • 3749
      • 24,544 Posts
      It’s been a long time since I had to mess with NewsPublisher so I may have misled you.

      I just looked in an old site and in the two user tables all the IDs are positive, while the createdby field has both positive and negative numbers.

      I know that web users have negative IDs (at least in some contexts), but the userids in the web user table are all positive and getLoginUserId() doesn’t seem to convert them so I’m officially baffled.

      Earlier in the NewsPublisher snippet, getLoginUserId() is called to get the id and it appears to just get the number in the user table, which would always be positive.

      You could try putting this after the getLoginUserID line at the top of NewsPublisher and seeing what you get in various situations:

      die("USER-ID: " . $userId);


      The original code that sets createdBy definitely sets the number negative if it’s positive and sets it to 0 if not. I’m not sure where this leaves you. I think NewsPublisher may be intended for use only in the front end for Web Users (since Manager Users have another way to create documents).

      Someone who knows the user ID scheme better than I do may have a better answer.


        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