How to add a new Validation
-
Hi,
I am using the brute-fore and changed the login page url. But when i add the new feild in the login page using the functions.php in my theme for validation it doesnt work. This is not effective using the brute force. But when i use the http://www.mywebsite.com/wp-login.php it works fine.
The code i wrote for adding additional feild and validation in my login is given below
add_action('login_form','my_added_login_field'); function my_added_login_field(){ //Output your HTML ?> <p> <label for="partner">Partner</label><br> <?php global $wpdb; $result=$wpdb->get_results( "SELECT * FROM hp3ic1e_partners"); ?> <select name="partnersname" id="partnership"> <?php foreach($result as $row) {?> <option value="<?php echo $row->partnername;?>"><?php echo $row->partnername;?></option> <?php } ?> </select> </p> <?php } add_filter( 'authenticate', 'my_custom_authenticate', 10, 3 ); function my_custom_authenticate( $user, $username, $password ){ //Get POSTED value $my_value = $_POST['partnersname']; //Get user object $user = get_user_by('login', $username ); //Get stored value $stored_value = get_user_meta($user->ID, 'user_partnership', true); if(!$user || empty($my_value) || $my_value !=$stored_value){ //User note found, or no value entered or doesn't match stored value - don't proceed. remove_action('authenticate', 'wp_authenticate_username_password', 20); //Create an error to return to user $user = new WP_Error( 'denied', __("<strong>ERROR</strong>: You're unique identifier was invalid.") ); } //Make sure you return null return null; }
https://wordpress.org/plugins/all-in-one-wp-security-and-firewall/
- The topic ‘How to add a new Validation’ is closed to new replies.