On March 26, 2019 we launched new MODX Forums. Please join us at the new MODX Community Forums.
Subscribe: RSS
  • Quote from: BobRay at Aug 06, 2018, 07:05 PM
    Thanks for reporting back.

    Are you saving timestamps or human-readable dates there? If it's the latter, it will be difficult (but not impossible) to do date arithmetic on them (e.g., "you've been a member for 2 years and 3 months").

    I should have remembered that the modUser object already has a createdon field (added somewhat recently), but not an editedon field. Since you're extending modUser, that could have caused your troubles. Using a different name for that field might have made it work as a date field.

    Hi thanks Bob, well I thought everything was working now, but for some reason there is another issue.

    I set up the postHooks field in register so it would email the Admin when a new user registers. I just called it like this:


    and then my snippet is the standard example:

    $message = 'Hi, a new User has registered on your site: '.$hook->getValue('username')
     . ' with email '.$hook->getValue('email').'.';
    $modx->getService('mail', 'mail.modPHPMailer');
    $modx->mail->set(modMail::MAIL_SUBJECT,'New App User Registration');
    if (!$modx->mail->send()) {
        $modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
    /* tell our snippet we're good and can continue */
    return true;

    (obviously with info@myemailaddress.com changed in both places to my actual email address - which may I add is an email that uses the same domain so shouldn't get blocked or rejected etc)

    But the modx Log just gives me this:

    [2018-09-17 14:53:02] (ERROR @ /public_html/core/cache/includes/elements/modsnippet/33.include.cache.php : 13) An error occurred while trying to send the email: 

    Has something changed with the newer versions of PHP that I need to alter the snippet, or can anyone else spot what is wrong. Not sure how to diagnose this further really. I've checked the email logs on the server and such and can't find anything there either. sad

    Thanks for any help.
      Yorkshire UK based hosting provider: https://www.simulant.uk
    • Does it work if you change



        If I help you out on these forums I would be very grateful if you would consider rating me on Trustpilot: https://uk.trustpilot.com/review/andytough.com

        email: andy@andytough.com | website: https://andytough.com
      • On some hosts, the EMAIL_FROM address must have an email account with the host. That's the most common cause of email failure in my experience.

        FWIW, I send all emails through Mailgun, which is free for several thousand emails per month and greatly improves deliverability, though it takes some effort to set up.
          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
        • Quote from: andytough at Sep 17, 2018, 06:33 PM
          Does it work if you change




          Thanks that did the trick! It is now working smiley
            Yorkshire UK based hosting provider: https://www.simulant.uk