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're retiring the forums!

The SilverStripe forums have passed their heyday. They'll stick around, but will be read only. We'd encourage you to get involved in the community via the following channels instead:

Archive /

Our old forums are still available as a read-only archive.

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

How To: A Simple Way to Moderate Page Comments

Go to End

4 Posts   3551 Views


Google Summer of Code Hacker, 222 Posts

30 June 2007 at 2:59pm

Edited: 30/06/2007 3:07pm

Hi Guys,

I just wanted to share some stuff that I've learned. :)

First off, you can enable Page Comments by editing a page, clicking on the "Behaviour" tab, checking the box next to "Allow comments on this page?", and saving the page.

By default, Page Comments do not have any protection against spam. This means that your pages can become spammed by robots.

One thing you can do is use the SSAkismet class to use spam detection for comments using
For more info on how to do this see:

However, I did not follow the above instructions because I didn't want to rely on a spam filtering service, I wanted to manually approve or delete every single comment by hand.

First I made it so that new comments are not shown by default. Here's how:
1. Open cms/code/sitefeatures/PageCommentInterface.php
2. Find this line:
$comment->IsSpam = false;
3. Replace that line with:
$comment->IsSpam = true;

Next, I needed to make the "this comment is not spam" link show up and work even though I did not enable SSAkismet. Here's how:
1. Open cms/code/sitefeatures/PageComment.php
2. Find these 3 lines:

if(SSAkismet::isEnabled() && Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
return "PageComment/reportham/$this->ID";

3. After the above 3 lines, add these 3 lines:

if(Permission::check('CMS_ACCESS_CMSMain') && $this->getField('IsSpam')) {
return "PageComment/reportham/$this->ID";

4. Find these 2 lines:

$comment->setField('IsSpam', false);

5. After those 2 lines, add the following 6 lines:

} else {
if (Permission::check('CMS_ACCESS_CMSMain')) {
$comment = DataObject::get_by_id("PageComment", $this->urlParams['ID']);
$comment->setField('IsSpam', false);

Ok, thankfully that's all the code changes we will need to make. :)

SilverStripe has a built-in RSS feed for Page Comments. You will want to subscribe to it at using your favorite feed reader.

For example, the URL for my Page Comments feed is:

Now when you see a new comment show up on your Page Comments RSS feed, you can do the following:
1. Login to the your SilverStripe CMS Admin Panel.
2. Visit the URL of the page where the Comment was posted (this will show up as a link in your feed reader)
3. Add ?showspam=1 to then end of the Page URL, for example:
4. If the new comment is not spam, them click the "this comment is not spam" link under it and it will start showing up on your page.
5. If the comment is spam, click the "remove this comment" link under it and it will be deleted.

There, an easy way to implement comment moderation. :)


Elijah Lofgren


2 Posts

26 July 2007 at 2:20am

Edited: 26/07/2007 2:22am

(My first post, so hello everyone.)

Thanks for sharing this, Elijah.

This method seems pretty straightforward, but is the code you've changed core code? Can I happily hack away without fear of this breaking when SS gets updated?

Many thanks,


Google Summer of Code Hacker, 222 Posts

31 July 2007 at 7:28am

Hi Alan,

Welcome to SilverStripe! :)

Yes it is core code, so upgrades will be a problem.

However, it seems that a better method of dealing with spam is coming our way soon :)

Have a good day,



Google Summer of Code Hacker, 222 Posts

8 August 2007 at 5:05am

I see:

static $moderate = false;

is now in so it looks like SilverStripe 2.1 will come with built-in comment moderation. :)