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.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

Forum Module /

Discuss the Forum Module.

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

Generate e-mail when new topic is created


Go to End


3 Posts   3688 Views

Avatar
joelg

Community Member, 134 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, 5523 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, 134 Posts

29 March 2009 at 2:14am

Thanks, this works great...