Skip to content

Instantly share code, notes, and snippets.

@1naveengiri
Last active January 4, 2019 07:01
Show Gist options
  • Save 1naveengiri/33a86a4b9ad1676f987ffdcdf4b5dbec to your computer and use it in GitHub Desktop.
Save 1naveengiri/33a86a4b9ad1676f987ffdcdf4b5dbec to your computer and use it in GitHub Desktop.
Awesome Support strong password check
<?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