Created
August 12, 2013 16:16
-
-
Save louy/6212415 to your computer and use it in GitHub Desktop.
Block Spam attacks on wp registeration page.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Registeration Anti-Spam | |
Plugin URI: https://gist.github.com/louy/6212415 | |
Description: Block Spam attacks on wp registeration page. | |
Author: Louy Alakkad | |
Version: 1.0 | |
Author URI: http://l0uy.com/ | |
*/ | |
function ras_get_field_name() { | |
return wp_nonce_tick(); | |
} | |
add_action( 'login_form_register', 'ras_login_form_register' ); | |
function ras_login_form_register() { | |
$field = ras_get_field_name(); | |
@$user_login = $_POST['user_login_'.$field]; | |
@$user_email = $_POST['user_email_'.$field]; | |
$_POST['user_login'] = $user_login; | |
$_POST['user_email'] = $user_email; | |
unset( $_POST['user_login_'.$field] ); | |
unset( $_POST['user_email_'.$field] ); | |
define( 'RAS_RUNNING', true ); | |
ob_start(); | |
} | |
add_action('login_footer', 'ras_login_footer'); | |
function ras_login_footer() { | |
if( defined( 'RAS_RUNNING' ) && RAS_RUNNING ) { | |
$output = ob_get_clean(); | |
$field = ras_get_field_name(); | |
$output = str_replace( | |
array('"user_login"', '"user_email"'), | |
array('"user_login_'.$field.'"', '"user_email_'.$field.'"'), | |
$output ); | |
echo $output; | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment