[SOLVED] Send Email Notification on Page Change NOT WORKING

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
joram
New Member
New Member
Posts: 6
Joined: Sat Dec 10, 2011 12:13 pm

[SOLVED] Send Email Notification on Page Change NOT WORKING

Post by joram »

I find this tip in the Wiki
http://wiki.cmsmadesimple.org/index.php ... age_Change

This is a UDT/Event combination that sends an email when a page is changed. This example uses the CMSMailer module (recommended).

First, create the following UDT named send_email_notification (or whatever name you want). Be sure to change the email address.

global $gCms;
$content =& $params['content'];

$editedby = $gCms->variables['username'];

$bodytext = '
A page on the web site has been changed.

Page Name: '.$content->Name().'
Page Alias: '.$content->Alias().'
Page Type: '.$content->Type().'
Page Created: '.$content->GetCreationDate().'
Modified on: '.$content->GetModifiedDate().'
Modified by: '.$editedby.'
Page URL: '.$content->GetURL();

$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress('your@email.com');
$cmsmailer->SetBody($bodytext);
$cmsmailer->IsHTML(false);
$cmsmailer->SetSubject('Page change notification--' .$content->Name());
$cmsmailer->Send();
Next, go to Extensions->Events, click the edit button for ContentEditPost, find your new UDT in the dropdown list, and ADD it.


The error is:

ERROR DETECTED: Call to a member function AddAddress() on a non-object at /path/lib/classes/class.usertagoperations.inc.php(243) : eval()'d code:18

Someone know where is the problem?
Thanks!
Last edited by joram on Sat Dec 10, 2011 3:12 pm, edited 1 time in total.
User avatar
Dr.CSS
Moderator
Moderator
Posts: 12711
Joined: Thu Mar 09, 2006 5:32 am

Re: [SOLVED] Send Email Notification on Page Change NOT WORK

Post by Dr.CSS »

Care to share how you solved it?...
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: [SOLVED] Send Email Notification on Page Change NOT WORK

Post by paulbaker »

I am getting exactly this problem. CMSMS 1.10.3. The "Send Email Notification on Page Change" UDT/Event was working perfectly on a previous version (1.9.4.1) but when I updated the CMSMS version, I noticed that whenever you save a page a PHP error was created. I switched off the UDT/Event and the page saves fine.

I think this is to do with the dropping support of $gCms which, as you can see in the previous post, appears in the UDT code.

But that's where, at the moment, my knowledge stops. :-\

Anybody?

Thanks ;D
joram
New Member
New Member
Posts: 6
Joined: Sat Dec 10, 2011 12:13 pm

Re: [SOLVED] Send Email Notification on Page Change NOT WORK

Post by joram »

Code: Select all

$cmsmailer =& cms_utils::get_module('CMSMailer');
User avatar
paulbaker
Dev Team Member
Dev Team Member
Posts: 1465
Joined: Sat Apr 18, 2009 10:09 pm
Contact:

Re: [SOLVED] Send Email Notification on Page Change NOT WORK

Post by paulbaker »

Hey joram

I changed

Code: Select all

$cmsmailer =& $gCms->modules['CMSMailer']['object'];
to

Code: Select all

$cmsmailer =& cms_utils::get_module('CMSMailer');
and the code now works in 1.10.3. Thank you for posting the solution. ;D
Post Reply

Return to “Modules/Add-Ons”