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

Into the Box 2024: Your Gateway to the Future of Tech!

Into the Box 2024: Your Gateway to the Future of Tech!

Are you ready to advance your coding skills? The future of Modern Web Development awaits at Into the Box 2024, and we're thrilled to announce that due to high demand, we're extending our Early Bird pricing for an additional week!

Maria Jose Herrera
Maria Jose Herrera
April 26, 2024
Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Hackers demand a ransom to restore data from my ColdFusion web applications!

Unfortunately, we often hear this message from clients who thought it would never happen to them... until it did. Some believed they could delay the expense of Implementing ColdFusion security best practices for one year, while others were tempted to put it off for just a few months. However, in today's rapidly evolving digital landscape, the security of web applications, including ColdFusio...

Cristobal Escobar
Cristobal Escobar
April 16, 2024
Ortus March Newsletter

Ortus March Newsletter

Welcome to Ortus Solutions’ monthly roundup, where we're thrilled to showcase cutting-edge advancements, product updates, and exciting events! Join us as we delve into the latest innovations shaping the future of technology.

Maria Jose Herrera
Maria Jose Herrera
April 01, 2024