
How to get admin user ID
Share This Post How to get admin User ID? It’s been really difficult for many to get back the admin user ID but it’s so
We usually get into wordpress site and don’t get password field registration form but it’s far way easier to access through this code snippet to get it now.
Let’s check how it is working…
This snippet will help you to add password field to the form.
/**
* Add password field to the form
*/
add_action( 'register_form', 'add_pass_field_to_register' );
function add_pass_field_to_register() {
$pass = ( ! empty( $_POST['user_pass'] ) ) ? $_POST['user_pass'] : '';
?>
The process of validating your password through this code snippet.
/** Validate user password
* @param $errors
* @param $sanitized_user_login
* @param $user_email
* @return mixed
*/
add_filter( 'registration_errors', 'validate_pass_register_field', 10, 3 );
function validate_pass_register_field( $errors, $sanitized_user_login, $user_email ) {
if ( empty( $_POST['user_pass'] ) || ! empty( $_POST['user_pass'] ) && trim(
$_POST['user_pass'] ) == '' ) {
$errors->add( 'user_pass_error', sprintf('%s: %s',__(
'ERROR', CRF_TEXT_DOMAIN ),__( 'You must include password.',
CRF_TEXT_DOMAIN ) ) );
}
return $errors;
}
Here this code snippet saves your password to the registration form easily.
* Save user password
*
* @param $user_id
*/
add_action( 'user_register', 'save_user_password' );
function save_user_password( $user_id ) {
if ( ! empty( $_POST['user_pass'] ) ) {
$password = trim( $_POST['user_pass'] );
wp_set_password( $password, $user_id );
}
So, All you need to add this code snippet to your theme functions.php file. Or download the plugin and install it on your server to add password field with your registration form. Enjoy!
Share This Post How to get admin User ID? It’s been really difficult for many to get back the admin user ID but it’s so
Share This Post Award GamiPress on RCPro Membership Renewal Do you think users can also be awarded points/badges/ranks while RCPro Membership renewal? Yes, you can
Share This Post Custom Message with myCRED Transfer MyCred assigns different points to the users but it’s been sometime noticed that the users want to
Once you send the details, we will be shortly back to you. Thanks!
This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.
Strictly Necessary Cookie should be enabled at all times so that we can save your preferences for cookie settings.
If you disable this cookie, we will not be able to save your preferences. This means that every time you visit this website you will need to enable or disable cookies again.