Jump to:

1036 Posts in 810 Topics by 315 members

Forum Module

SilverStripe Forums » Forum Module » Generate e-mail when new topic is created

Discuss the Forum Module.

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

Page: 1
Go to End
Author Topic: 2170 Views
  • joelg
    Avatar
    Community Member
    129 Posts

    Generate e-mail when new topic is created Link to this post

    Hi Everyone

    Can someone tell me, how you could generate an e-mail everytime a new topic is created in the forum?

    Thanks!

    Joel

  • Willr
    Avatar
    Forum Moderator
    5508 Posts

    Re: Generate e-mail when new topic is created Link to this post

    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.

  • joelg
    Avatar
    Community Member
    129 Posts

    Re: Generate e-mail when new topic is created Link to this post

    Thanks, this works great...

    2170 Views
Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.