Blog

Luis Majano

July 22, 2016

Spread the word


Share your thoughts

ContentBox sports many out of the box comment moderation tools.

From the screenshot you can appreciate all the different tuning you can do for comment moderation:

  • All comments moderated
  • User must have an approved comment to be approved consequentely
  • Auto-deletion of comments that are moderated
  • Moderated keywords (ip addresses, authors, emails, or content)
  • Blocked keywords (ip addresses, authors, emails, or content)

My favorite setting is the auto-deletion of moderated comments. I have never ever ever ever cleaned up spam anymore. I let ContentBox do it every X number of days and I truly appreciate that as it is one less thing to worry about.

Comment Events

As you can see, you have many options when it comes to comment moderation and even blocking. You can also tap into the commenting life-cycle with interception events. Below are all the events you can listen to that deal with comments:

  • cbui_preCommentPost - Before a comment is posted
  • cbui_onCommentPost - After a comment is posted
  • cbui_onCommentModerationRules - After all comment moderation and blocking rules have executed. Your chance to change them or add to them.
  • cbadmin_onCommentStatusUpdate - When the status of a comment is changed
  • cbadmin_preCommentSave - Before a comment is saved by an editor
  • cbadmin_postCommentSave - After a comment is saved by an editor
  • cbadmin_preCommentRemove - Before a comment is removed
  • cbadmin_postCommentRemove - After a comment is removed
  • cbadmin_preCommentRemoveAllModerated - Before all comments moderated comments are auto-deleted
  • cbadmin_postCommentRemoveAllModerated - After all comments moderated comments are auto-deleted
  • cbadmin_preCommentSettingsSave - Before saving comment settings
  • cbadmin_postCommentSettingsSave - After saving comment settings
  • cbadmin_onCommentSettingsNav - On the comment navigation tab
  • cbadmin_onCommentSettingsContent - On the comment content tab

All you have to do is create interceptors or modules that listen to these event functions and you can extend ContentBox your way. Here is a real example from our Akismet moderating module:

function cbui_onCommentModerationRules( event, interceptData, buffer ){
	var oComment = arguments.interceptData.comment;
	var settings = coldbox.getSetting( "modules" )[ "contentbox-akismet" ].settings;
	
	// check if key is empty? If it is, just return
	if( !len( settings.api_key ) ){
		return;
	}		

	// verify if spam?
	var isSpam = akismet.isCommentSpam(
		author = oComment.getAuthor(),
		authorURL = oComment.getAuthorURL(),
		authorEmail = oComment.getAuthorEmail(),
		content = oComment.getContent(),
		permalink = cb.linkContent( oComment.getRelatedContent() )
	);

	// if block is setup and comment is spam, then ignore.
	if( settings.block and isSpam ){
		oComment.setIsApproved( false );
		arguments.interceptData.allowSave = false;
		log.info( "Incoming comment is spam and block enabled, ignoring comment.", oComment.getMemento() );
	}
	// else, if spam, mark it
	else if( !settings.block AND isSpam ){
		oComment.setIsApproved( false );
		log.info( "Incoming comment is spam so moderating it.", oComment.getMemento() );
	}

}

Add Your Comment

Recent Entries

ColdBox 7.2.0 Released

ColdBox 7.2.0 Released

ColdBox, a widely used development platform for ColdFusion (CFML), has unveiled version 7.2. Packed with compelling new features, bug fixes, and enhancements, this release is designed to empower developers by boosting productivity, refining scheduled task capabilities, and enhancing the overall reliability and efficiency of application development. This article will delve into the key highlights of ColdBox 7.2 and elucidate how these advancements can positively impact developers in their daily coding endeavors.

Luis Majano
Luis Majano
November 20, 2023
Into the Box 2023 Series on CFCast

Into the Box 2023 Series on CFCast

Excitement is in the air as we unleash the highly anticipated ITB 2023 series exclusively for our valued CFCast subscribers – and the best part? It's FREE for CFCast members! Now is the perfect time if you haven't joined the CFCast community yet. Plus, we've got an incredible End-of-Year deal that's too good to miss

Maria Jose Herrera
Maria Jose Herrera
November 20, 2023
Ortus Deals are Finally Here!

Ortus Deals are Finally Here!

The much-anticipated Ortus End-of-the-Year Sale has arrived, and it's time to elevate your development experience! Whether you're a seasoned developer, a tech enthusiast, or someone on the lookout for top-notch projects, Ortus has something special in store for you. Brace yourself for incredible discounts across a wide array of products and services, including Ortus annual events, books, cutting-edge services, and more.

Maria Jose Herrera
Maria Jose Herrera
November 15, 2023