Quote from: BobRay at Aug 06, 2018, 07:05 PMThanks 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:
<?php
$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_BODY,$message);
$modx->mail->set(modMail::MAIL_FROM,'[email protected]');
$modx->mail->set(modMail::MAIL_FROM_NAME,'Test');
$modx->mail->set(modMail::MAIL_SENDER,'Test');
$modx->mail->set(modMail::MAIL_SUBJECT,'New App User Registration');
$modx->mail->address('to','[email protected]');
$modx->mail->setHTML(true);
if (!$modx->mail->send()) {
$modx->log(modX::LOG_LEVEL_ERROR,'An error occurred while trying to send the email: '.$err);
}
$modx->mail->reset();
/* tell our snippet we're good and can continue */
return true;
(obviously with
[email protected] 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.
Thanks for any help.