Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

Forum Module /

Discuss the Forum Module.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Generate e-mail when new topic is created


Reply


3 Posts   2422 Views

Avatar
joelg

Community Member, 129 Posts

16 March 2009 at 8:52am

Edited: 16/03/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

Avatar
Willr

Forum Moderator, 5513 Posts

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.

Avatar
joelg

Community Member, 129 Posts

29 March 2009 at 2:14am

Thanks, this works great...