Use Events to Send an Email when a Page is Edited?
Re: Use Events to Send an Email when a Page is Edited?
Maybe there's something wrong with your mail() function?
Re: Use Events to Send an Email when a Page is Edited?
no no. like i said before, when i change a page and send an email, IT WORKS!!! But when adding a new user, it doesnt work!
Re: Use Events to Send an Email when a Page is Edited?
IT WORKS!!!
My mistake was a dash in the UDT name:
send-mail
is not working (warum auch immer)
That is the reason why the other method with the cmsmailer was not working as well!
My mistake was a dash in the UDT name:
send-mail
is not working (warum auch immer)
That is the reason why the other method with the cmsmailer was not working as well!
Last edited by SimonSchaufi on Tue Aug 14, 2007 7:24 pm, edited 1 time in total.
Re: Use Events to Send an Email when a Page is Edited?
You can read the reason hereSimonSchaufi wrote: send-mail
is not working (warum auch immer)
http://forum.cmsmadesimple.org/index.ph ... 205.0.html
(in german)
Re: Use Events to Send an Email when a Page is Edited?
Here my solution (a bit tuned
):
Make sure you dont save it with a dash in the UDT name!
There is no possibility to get the password as plain text so you need to catch it from the POST var.
If nobody has any other suggestions, i will post it in the wiki

Make sure you dont save it with a dash in the UDT name!
Code: Select all
function validate_email($email){
$exp = "^[a-z\'0-9]+([._-][a-z\'0-9]+)*@([a-z0-9]+([._-][a-z0-9]+))+$";
if(eregi($exp,$email)){
if(checkdnsrr(array_pop(explode("@",$email)),"MX")){
return true;
}else{
return false;
}
}else{
return false;
}
}
global $gCms;
$sitename = get_site_preference('sitename', 'My Homepage'); /* If sitename is not set, use My Homepage */
$newuser =& $params['user'];
$bodytext = 'This is your new user account information:
First Name: '.$newuser->firstname.'
Last Name: '.$newuser->lastname.'
Username: '.$newuser->username.'
Password: '.$_POST["password"].'
Email: '.$newuser->email.'
Login here: '.$gCms->config["root_url"].DIRECTORY_SEPARATOR.$gCms->config["admin_dir"].'
After login please change your password here: My Preferences -> My Account!';
if($newuser->email != "" && validate_email($newuser->email)){
$cmsmailer =& $gCms->modules['CMSMailer']['object'];
$cmsmailer->AddAddress($newuser->email);
$cmsmailer->SetBody($bodytext);
$cmsmailer->IsHTML(false);
$cmsmailer->SetSubject($sitename.' User Account Information');
$cmsmailer->Send();
}
If nobody has any other suggestions, i will post it in the wiki
Last edited by SimonSchaufi on Wed Aug 15, 2007 11:47 am, edited 1 time in total.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Use Events to Send an Email when a Page is Edited?
When working with events, each event will return different items in $params. You have to check for this on a handler, by handler basis.
i.e: $params['content'] may not exist for every event, it may be something different, and even if it is..... it may not be a reference to an object, etc.
There is help for each event that describes what parameters are delivered (somewhat), and this would be a great place to start. After that, I'd start with:
print_r( $params ); die();
for every event handler, and then go from there.
i.e: $params['content'] may not exist for every event, it may be something different, and even if it is..... it may not be a reference to an object, etc.
There is help for each event that describes what parameters are delivered (somewhat), and this would be a great place to start. After that, I'd start with:
print_r( $params ); die();
for every event handler, and then go from there.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- Support Guru
- Posts: 8169
- Joined: Tue Oct 19, 2004 6:44 pm
- Location: Fernie British Columbia, Canada
Re: Use Events to Send an Email when a Page is Edited?
I just looked at the source, and a skilled module developer could write a module, using Events to add versioning into CMS Made Simple. It's a very nice system, the Events give CMS Made simple an extreme amount of flexibility and customising capability with just a bit of programming knowledge.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
-
- Forum Members
- Posts: 12
- Joined: Tue Nov 06, 2007 10:21 pm
Re: Use Events to Send an Email when a Page is Edited?
How could this code (i.e the UDT in the wiki called "Send Email Notification on Page Change") be set up to send a notification to a dynamic group of recipients rather than an individual or unchanging group of recipients? I'm developing a site now for a school and the teachers will have their own pages to post notes for parents to check. An existing web-based solution which I am trying to emulate in the CMS allows the teacher to send a notification when their page is updated to the parents' email addresses. If a mailing list can be set up inside CMSMS (such as in the NMS module), can that be a basis for sending an email notification using Events?
Re: Use Events to Send an Email when a Page is Edited?
Maybe you should use FrontendUsers module?
It has an own event if user data are changed ...
It has an own event if user data are changed ...