939 Posts in 271 Topics by 291 members
Forum Module
SilverStripe Forums » Forum Module » Generate e-mail when new topic is created
Discuss the Forum Module.
Moderators: martimiz, Howard, Sean, Ryan M., biapar, Willr, Ingo, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 1662 Views |
-
Generate e-mail when new topic is created

16 March 2009 at 8:52am Last edited: 16 March 2009 8:52am
Hi Everyone
Can someone tell me, how you could generate an e-mail everytime a new topic is created in the forum?
Thanks!
Joel
-
Re: Generate e-mail when new topic is created

21 March 2009 at 2:15pm
No super clean way to do this but adding this is pretty easy its just you have to edit the Forum.php file (makes upgrading harder as you can override the code).
But to do it all you would need to do is add this near the end of the postAMessage() function in forum/code/Forum.php file on about line 1011 you should currently have (make sure your using 0.2)
if($post->ParentID == 0) {
$post->TopicID = $post->ID;
// Extra write() that we can't avoid because we need to set
// $post->ID which is only created when the object is written to the
// database
$post->write();
}You can add a piece of code inside that if to send the email
if($post->ParentID == 0) {
$post->TopicID = $post->ID;
// Extra write() that we can't avoid because we need to set
// $post->ID which is only created when the object is written to the
// database
$post->write();
// send an email
$email = new Email('enteryour@email.com', "New Forum Thread Created", "You have a new Forum Thread");
$email->send();
}Usually for keeping track of forum posts, threads using RSS feeds are more dynamic and powerful then email.
| 1662 Views | ||
|
Page:
1
|
Go to Top |


