We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • I’m going to be building a Revo site shortly which involves people gaining access to documents via a login and downloading PDF docs and such. Curious if anyone has handled action reporting before to view the actions by the users who gained access? For example, when John Doe logs into the front of the site (not the manager area), downloads a document, how would I be able to track and record that info for download later? Curious if anyone knows of a plugin that can be user in MODx, hacked or otherwise, or have had experience doing this.
      Precision Web Development ... SmashStack.com
    • You probably could pull this off using a Plugin that writes data to a file or to a custom database table. It depends on what actions you want to log, though. Assuming you just wanted to log page views for logged in users, you could trigger your plugin code using the OnLoadWebDocument (I think?? One of these events would handle that). Your plugin code could check if there was a user logged in, and if yes, then write the information to the database or to a file, storing columns for username, page URL, and a timestamp.

      Perhaps there’s a more elegant solution to that, but I think the above would work.
        • 3749
        • 24,544 Posts
        This will put a message about the event in the Manager Actions log:

        $modx->logManagerAction(string $action, string $class_key, mixed $item) — Log an event to the Manager Action log. $action is the lexicon key of the event (e.g., ’chunk_create’, ’resource_update’). $class_key is the class key of the object the action is performed on (e.g., ’modChunk’, ’modResource’). $item is the ID or array of IDs for the object(s) being acted on (e.g., $resource->get(’id’)).

        Here’s an example from the ActivationEmail plugin:

        $modx->logManagerAction($eventName,'modUser',$user->get('id'));


        You can then view the actions in Reports -> Manager Actions. The report can be filtered by user, action, and/or date, but there’s no way at present to download it (nice feature request though).


        You could also write whatever you want to a file with $modx->log() after using setLogTarget() to point to your file (don’t forget to set it back after logging the info). I think that’s what I would do. Something like this:

        <?php
        $oldTarget = $modx->setLogTarget('FILE');
        $target = array(
            'target' => 'FILE',
            'options' => array(
                'filename' => 'path_to_file'),
        );
        $msg = 'Joe Blow saved a file at ' . time();
        
        $modx->log(xPDO::LOG_LEVEL_INFO, $msg, $target);
        
        $modx->setLogTarget($oldTarget);
        
        


          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
        • Hey BobRay,

          Thanks so much for the response...greatly appreciated! I’ll take a look into this and try it out.
            Precision Web Development ... SmashStack.com