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

BoxLang 1.0.0 Beta 7 Launched

BoxLang 1.0.0 Beta 7 Launched

We are pleased to announce the release of BoxLang 1.0.0-Beta 7! This latest beta version includes improvements and essential bug fixes, but more importantly it certifies the execution of ColdBox HMVC and TestBox.

What is BoxLang?

BoxLang is a modern dynamic JVM language that can be deployed on multiple runtimes: operating system (Windows/Mac/*nix/Embedded), web server, lambda, iOS, android, web assembly, and more. BoxLang combines many features from different progr

Luis Majano
Luis Majano
July 26, 2024
New BoxLang Feature: Java Method References and Higher-Order Functions

New BoxLang Feature: Java Method References and Higher-Order Functions

We’ve added more goodies to our BoxLang Java interop: method references and higher-order functions. CFML has never let you do these things, making Java Interop feel like a second-class citizen. But with BoxLang, we’re elevating Java integration to a new level.

Maria Jose Herrera
Maria Jose Herrera
July 26, 2024
Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Level Up Your ColdFusion Skills with our Virtual Live Training: ColdBox from Zero to Hero

Are you a CFML developer looking to take your skills to the next level? Look no further than the ColdBox from Zero to Hero Virtual Live Training! This intensive two-day course will equip you with the knowledge and expertise to build robust and scalable applications using ColdBox 7, the latest version of the most popular CFML MVC framework.

What You'll Learn:

  • Master the Fun...

Cristobal Escobar
Cristobal Escobar
July 24, 2024