Last active
January 4, 2019 07:01
-
-
Save 1naveengiri/33a86a4b9ad1676f987ffdcdf4b5dbec to your computer and use it in GitHub Desktop.
Awesome Support strong password check
This file contains hidden or 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 | |
// this action get fire during registration process. | |
add_action('wpas_pre_register_account','wpas_pre_register_account_callback', 10, 3); | |
function wpas_pre_register_account_callback( $user, $redirect_to, $data ){ | |
if( !is_pwd_strong( $user['pwd'] ) ){ | |
wpas_add_error( 'accept_terms_conditions', esc_html__( 'Add strong password', 'awesome-support' ) ); | |
wp_safe_redirect( $redirect_to ); | |
exit; | |
} | |
} | |
/** | |
* Function to check if password is strong. | |
* | |
* @param string $pwd password | |
*/ | |
function is_pwd_strong( $pwd ){ | |
$is_strong = true; | |
// add security checks based on your need | |
if (strlen($pwd) < 8) { | |
$is_strong = false; | |
} | |
return $is_strong; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment