PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Profanity filter possible on post form?

  1. I have a form that takes user input and makes a post that is visible right away (no moderation, I suggested they not do this). However they would like to know if a profanity filter is possible so that it profanity is detected the post is kept but not published, with an email getting fired off.

    Is this possible? What hooks would you suggest if so?

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  2. David Peralty

    So you want it to be a draft if the post trips a profanity filter? This would require customization. You would want to use the post_submission_filter, check all the submitted content for bad words, and then change it to draft if it fails the check. It seems like it could be a bit intense if the post body is long, but it is possible.

    Posted 11 years ago on Friday June 14, 2013 | Permalink
  3. We managed to get it done with gform_confirmation.

    Check it out here (until late July 2013 when contest ends)
    http://skypestaytogether.com/contest-entry/

    add_filter("gform_confirmation", "custom_confirmation", 10, 4);
    function custom_confirmation($confirmation, $form, $lead, $ajax){
    	$gfe = $lead['id'];
    	$storyTitle=$lead['4'];
    	$storyBody=$lead['2'];
    
    	$body = $storyBody." ".$storyTitle;
    	if (($form["id"] == "3")|| ($form["id"] == "5")){
    		if (containsProfanity($body)){
    			$confirmation = array('redirect' => home_url().'/thank-you');
    			changePostToDraft($lead);
    			$confirmation = array('redirect' => home_url().'/review-entry/?e='.$gfe);
    		} else {
    		$confirmation = array('redirect' => home_url().'/thank-you');
    		}
    		return $confirmation;
    	}
    }
    
    function containsProfanity($text){
    //our check went here
    }
    Posted 11 years ago on Wednesday June 26, 2013 | Permalink

This topic has been resolved and has been closed to new replies.