We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32025
    • 305 Posts
    I looked up this error in the MODx forums, it seems like it can be many things. After reading many posts I am still completely confused as to what would cause this error. I tried re-uploading the page, still same error. I looked in core/cache/logs/error.log and I see this:
    [2013-05-06 19:16:13] (ERROR @ /index.php) Attempted to redirect to an empty URL.
    [2013-05-06 19:51:45] (ERROR @ /connectors/security/user.php) Could not get table class for class: modAccess
    [2013-05-06 19:51:45] (ERROR @ /connectors/security/user.php) Could not get table name for class: modAccess
    [2013-05-06 19:51:45] (ERROR @ /connectors/security/user.php) Error 42000 executing statement: 
    Array
    (
        [0] => 42000
        [1] => 1064
        [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 18' at line 1
    )
    
    [2013-05-06 17:36:54] (ERROR @ /connectors/security/user.php) Could not get table class for class: modAccess
    [2013-05-06 17:36:54] (ERROR @ /connectors/security/user.php) Could not get table name for class: modAccess
    [2013-05-06 17:36:54] (ERROR @ /connectors/security/user.php) Error 42000 executing statement: 
    Array
    (
        [0] => 42000
        [1] => 1064
        [2] => You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'AS `modAccess` WHERE `modAccess`.`principal` = 17' at line 1
    )

    These are repeated around 19 times in the log, but the error.log does not seem to match the error on the page. Not even sure if these 2 are related, but I am guessing they have too.

    I am clueless as to what could be showing the blank page with PHP error. Anyone?
      Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
      • 3749
      • 24,544 Posts
      In the front end, you would need to use this:

      $username = $modx->user->get('username');



      This version would be appropriate in a plugin connected to one of the user-related events:

      $username = $user->get('username');


      Not sure if that will solve your problem.
        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
      • Useful thread! I was just needing to do this very thing.

        In the process() method of the LoginConfirmRegisterController class (ConfirmRegister.php) you can get the user name with $this->user->get('username'). Also $modx should be $this->modx.

        I modified the code the code to fix these things and also added a few features for the project I'm working on:
        $username = $this->user->get('username');
        $usergroups = implode($this->user->getUserGroupNames(), ', ');  // I also want to include what groups a person has signed up for
        $siteurl = $this->modx->getOption('site_url') . ltrim(MODX_MANAGER_URL, '/') . 'index.php?a=56';  // a link to 'Manage Users' in the Manager
        $adminEmail = $this->modx->getOption('admin.email');  // I created an admin.email setting in System Settings
         
        $this->modx->getService('mail', 'mail.modPHPMailer');
        $this->modx->mail->set(modMail::MAIL_BODY, "put your email body in here, or better, get it from a chunk");
        $this->modx->mail->set(modMail::MAIL_FROM, $adminEmail);
        $this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('site_name'));
        $this->modx->mail->set(modMail::MAIL_SENDER, $adminEmail);
        $this->modx->mail->set(modMail::MAIL_SUBJECT, 'subject goes here');
        $this->modx->mail->setHTML(true);  // HTML email
        $this->modx->mail->address('to', $adminEmail, $adminEmail);
        $this->modx->mail->address('reply-to', $adminEmail);
        $sent = $this->modx->mail->send();
          Extras :: pThumbResizerimageSlimsetPlaceholders
          • 32025
          • 305 Posts
          Quote from: jgrant at May 16, 2013, 09:23 PM
          Useful thread! I was just needing to do this very thing.

          In the process() method of the LoginConfirmRegisterController class (ConfirmRegister.php) you can get the user name with $this->user->get('username'). Also $modx should be $this->modx.

          I modified the code the code to fix these things and also added a few features for the project I'm working on:
          $username = $this->user->get('username');
          $usergroups = implode($this->user->getUserGroupNames(), ', ');  // I also want to include what groups a person has signed up for
          $siteurl = $this->modx->getOption('site_url') . ltrim(MODX_MANAGER_URL, '/') . 'index.php?a=56';  // a link to 'Manage Users' in the Manager
          $adminEmail = $this->modx->getOption('admin.email');  // I created an admin.email setting in System Settings
           
          $this->modx->getService('mail', 'mail.modPHPMailer');
          $this->modx->mail->set(modMail::MAIL_BODY, "put your email body in here, or better, get it from a chunk");
          $this->modx->mail->set(modMail::MAIL_FROM, $adminEmail);
          $this->modx->mail->set(modMail::MAIL_FROM_NAME, $this->modx->getOption('site_name'));
          $this->modx->mail->set(modMail::MAIL_SENDER, $adminEmail);
          $this->modx->mail->set(modMail::MAIL_SUBJECT, 'subject goes here');
          $this->modx->mail->setHTML(true);  // HTML email
          $this->modx->mail->address('to', $adminEmail, $adminEmail);
          $this->modx->mail->address('reply-to', $adminEmail);
          $sent = $this->modx->mail->send();

          Jgrant first off this is and awesome addition to this post! I was able to send an e-mail during testing after your tweaks so it works. But I have a few easy questions:
          As far as this coding:
          $this->modx->mail->set(modMail::MAIL_BODY, "put your email body in here, or better, get it from a chunk");


          If I create a chunk for this e-mail (as you recommend) that is called: adminNotice how would I put this chunk into this coding. Like this:
          $this->modx->mail->set(modMail::MAIL_BODY, "[[$adminNotice]] ");
          ?

          Second, I notice that you call up the site URL and the username, but they do not show in the e-mail that is being sent. Would I add them to the chunk? Like this: [[+siteurl]] and [[+username]]? I don't know how to get the URL and username into the e-mail properly. It looks like you define them, but I don't know how to call them in the e-mail. Sorry for the simple questions.
            Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
          • As a string, you could do something like:
            $mailBody = "<p><strong>New Registration:</strong></p><table><tr><td>User: </td><td>$username</td></tr><tr><td>Groups: </td><td>$usergroups</td></tr></table><br /><p><a href='$siteurl'>Manage User Accounts</a></p>";
            $this->modx->mail->set(modMail::MAIL_BODY, $mailBody);
            


            Or to use a chunk:
            $mailBody = $this->modx->getChunk('notificationTpl', array(
                'user' => $username,
                'groups' => $usergroups,
                'url' => $siteurl
            ));
            $this->modx->mail->set(modMail::MAIL_BODY, $mailBody);
            


            Then create a chunk called notificationTpl with this:
            <p><strong>New Registration:</strong></p>
            <table>
            <tr><td>User: </td><td>[[+user]]</td></tr>
            <tr><td>Groups: </td><td>[[+groups]]</td></tr>
            </table>
            <br />
            <p><a href='[[+url]]'>Manage User Accounts</a></p>
            
              Extras :: pThumbResizerimageSlimsetPlaceholders
              • 32025
              • 305 Posts
              Yeah!!! Works like a charm. I decided to go with the Chunk per your recommendation and it works well. Thank you for following up, I think others might find this post useful!

              Problem Solved!!
                Making the web a better place on site at a time! Dayton Web Design: http://www.dayton-web-design.com/
              • Problem Solved!!

                Great! I'm glad between all of us in this thread we've come up with something which works.
                  Extras :: pThumbResizerimageSlimsetPlaceholders