How To Automatically Refuse Comment without Plugin


Sponsored Links






For many year Spam is the big enemy on internet, there are so many way to Automatically Refuse Comment, some tricks need installed some plugin such as Akismet, WP-Spamfree, Bad Behavior and many more, But I will show you how to do this without Plugin, all need to do only added some code on functions.php on your themes.

This code is original created by Guy and republish by WP Recipes, let’s get started

function in_comment_post_like($string, $array) {
	foreach($array as $ref) { if(strstr($string, $ref)) { return true; } }
	return false;
}
function drop_bad_comments() {
	if (!empty($_POST['comment'])) {
		$post_comment_content = $_POST['comment'];
		$lower_case_comment = strtolower($_POST['comment']);
		$bad_comment_content = array(
			'viagra',
			'hydrocodone',
			'hair loss',
			'[url=http',
			'[link=http',
			'xanax',
			'tramadol',
			'russian girls',
			'russian brides',
			'lorazepam',
			'adderall',
			'dexadrine',
			'no prescription',
			'oxycontin',
			'without a prescription',
			'sex pics',
			'family incest',
			'online casinos',
			'online dating',
			'cialis',
			'best forex',
			'amoxicillin'
		);
		if (in_comment_post_like($lower_case_comment, $bad_comment_content)) {
			$comment_box_text = wordwrap(trim($post_comment_content), 80, "n  ", true);
			$txtdrop = fopen('/var/log/httpd/wp_post-logger/nullamatix.com-text-area_dropped.txt', 'a');
			fwrite($txtdrop, "  --------------n  [COMMENT] = " . $post_comment_content . "n  --------------n");
			fwrite($txtdrop, "  [SOURCE_IP] = " . $_SERVER['REMOTE_ADDR'] . " @ " . date("F j, Y, g:i a") . "n");
			fwrite($txtdrop, "  [USERAGENT] = " . $_SERVER['HTTP_USER_AGENT'] . "n");
			fwrite($txtdrop, "  [REFERER  ] = " . $_SERVER['HTTP_REFERER'] . "n");
			fwrite($txtdrop, "  [FILE_NAME] = " . $_SERVER['SCRIPT_NAME'] . " - [REQ_URI] = " . $_SERVER['REQUEST_URI'] . "n");
			fwrite($txtdrop, '--------------**********------------------'."n");
			header("HTTP/1.1 406 Not Acceptable");
			header("Status: 406 Not Acceptable");
			header("Connection: Close");
			wp_die( __('bang bang.') );
		}
	}
}
add_action('init', 'drop_bad_comments');

Save your functions.php and done ;) I hope this code about How To Automatically Refuse Comment without Plugin will help you to trow away your SPAM Comment. You can extend the words by added more array on code above

Subscribe to Full RSS Feed

RSS FeedIf you thing this article useful, please consider subscribing to our RSS Feed or e-mail updates and stay updated with us. You can also follow @WPTricksNet on twitter for latest updates.

About WP Tricks

We are WordPress Family, we collected and writed useful tips and tricks for you WordPress. We share it for you...

Related Tips and Trick from Local Data and on The Net

Remove nofollow attributes from comment text

WordPress added nofollow attributes on comment text url, this is bad for some commeter that needed some backlinks, if you want remove nofollow attributes from comment text in your WordPress site is easely, all need to do just added some … Read More

Get Recent Comment with Gravatar without plugin

Many WordPress User need to display Recent Comment on the sidebar or footer with Gravatar, most of them using plugin, right now I will show you how to Get Recent Comment with Gravatar without plugin. All need to do just … Read More

How To Enable Keyboard Shortcuts on WordPress Comment

Another WordPress great features is supporting Keyboard Shortcut. Using Keyboard Shortcut, comment moderation much simple, easier and quicker than ever. This WordPress Guide will show you how to enable keyboard shortcuts on WordPress comment

How To Display Custom Content to Search Engine Visitors

There are so many WordPress blog, some of them added unique features, right now I will show you how to display custom content to Search Engine visitors only, You can replace what do you want to be added on Search … Read More

How To Linking to all image sizes in WordPress

This is latest Justin Tadlock tutorial, on January 2011. Using the functions that Justin created wonderful method to display all image size link, it's flickr like method. We can put it on example attachment.php or image.php There are two steps

How To Create Popular Post without Plugin

Today WP Tricks is how to create popular post without any plugin. We need to run little bit query using some code and place this code on whatever you want to put on. Example we can put this code on … Read More

kisah seks panas - WordPress Tricks & Tips

How To Automatically Refuse Comment without Plugin January 21st, 2011 By WP Tricks Posted in Tips read more

Source: http://wptricks.net/archives/kisah-seks-panas?amp

anh++hinh++anh+dep+hinh+dep+gai+dep+girl+xinh+nguoi+lon

Daily The Best WordPress Tricks and WordPress Tips to make your How To Automatically Refuse Comment without Plugin read more

Source: http://wptricks.net/archives/anh+sex+hinh+sex+anh+dep+hinh+dep+gai+dep+girl+xinh+nguoi+lon

Automatically refuse spam comments on your WordPress blog

Automatically refuse spam comments on words contained within the $bad_comment_content array will be automatically tweets on your WordPress blog without any plugin read more

Source: http://www.wprecipes.com/automatically-refuse-spam-comments-on-your-wordpress-blog

Easy Way to Avoid Spam Comments Entering Your WordPress Blog

Here is a code to automatically forbid What if you can refuse entry to spammers and comment bots into your to moderate: both with and without Akismet plugin. read more

Source: http://www.speckygeek.com/keep-spam-comment-bots-away-from-wordpress/

blogwaffe ยป AJAX Comment Preview

Get the plugin from the Ajax Comment Preview page in the The plugin really should just refuse to activate without PHP5. and paragraph breaks are inserted automatically read more

Source: http://blogwaffe.com/ajax-comment-preview/


2 Responses to How To Automatically Refuse Comment without Plugin

  1. Pingback: Automatically empty Trash | Unlock IMEI Cellphones

  2. Pingback: Automatically Shorten your Permalink using Bit.ly services | Unlock IMEI Cellphones

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>