i well use a Wordpress template with modal login and registration form, i need get password from user in registration form instead auto generating by wp-generate-password() function!
this is my modal registration form:
<div class="form-wrapper">
<div class="form-heading clearfix">
<span><?php _e( 'Register', 'inspiry' ); ?></span>
<button type="button" class="close close-modal-dialog" data-dismiss="modal" aria-hidden="true"><i class="fa fa-times fa-lg"></i></button>
</div>
<form id="register-form" action="<?php echo admin_url('admin-ajax.php'); ?>" method="post" enctype="multipart/form-data">
<div class="form-element">
<label class="login-form-label" for="register_username"><?php _e( 'Username', 'inspiry' ); ?><span>*</span></label>
<input id="register_username" name="register_username" type="text" class="login-form-input login-form-input-common"
title="<?php _e( '* Please enter a valid username.', 'inspiry' ); ?>"
placeholder="<?php _e( 'Username', 'inspiry' ); ?>" />
</div>
<div class="form-element">
<label class="login-form-label" for="register_password"><?php _e( 'Password', 'inspiry' ); ?><span>*</span></label>
<input id="register_password" name="register_password" type="password" class="login-form-input login-form-input-common"
title="<?php _e( '* Please provide strong password!', 'inspiry' ); ?>"
placeholder="<?php _e( 'Password', 'inspiry' ); ?>" />
</div>
<div class="form-element">
<label class="login-form-label" for="register_email"><?php _e( 'Email', 'inspiry' ); ?><span>*</span></label>
<input id="register_email" name="register_email" type="text" class="login-form-input login-form-input-common"
title="<?php _e( '* Please provide valid email address!', 'inspiry' ); ?>"
placeholder="<?php _e( 'Email', 'inspiry' ); ?>" />
</div>
<div class="form-element clearfix">
<input type="submit" id="register-button" name="user-submit" class="login-form-submit login-form-input-common" value="<?php _e( 'Register', 'inspiry' ); ?>" />
<input type="hidden" name="action" value="inspiry_ajax_register" />
<?php // nonce for security
wp_nonce_field( 'inspiry-ajax-register-nonce', 'inspiry-secure-register' );
if ( is_page() || is_single() ) {
?><input type="hidden" name="redirect_to" value="<?php wp_reset_postdata(); global $post; the_permalink( $post->ID ); ?>" /><?php
} else {
?><input type="hidden" name="redirect_to" value="<?php echo esc_url( home_url( '/' ) ); ?>" /><?php
}
?>
<div class="text-center">
<div id="register-message" class="modal-message"></div>
<div id="register-error" class="modal-error"></div>
<img id="register-loader" class="modal-loader" src="<?php echo get_template_directory_uri(); ?>/images/ajax-loader.gif" alt="Working...">
</div>
</div>
</form>
<div class="clearfix">
<span class="login-link pull-left">
<a href="#" class="activate-section" data-section="login-section"><?php _e( 'Login', 'inspiry' ); ?></a>
</span>
<span class="forgot-password pull-right">
<a href="#" class="activate-section" data-section="password-section"><?php _e( 'Forgot Password?', 'inspiry' ); ?></a>
</span>
</div>
and this is the form handler:
if( !function_exists( 'inspiry_ajax_register' ) ) :
/**
* AJAX register request handler
*/
function inspiry_ajax_register() {
// First check the nonce, if it fails the function will break
check_ajax_referer( 'inspiry-ajax-register-nonce', 'inspiry-secure-register' );
// Nonce is checked, Get to work
$info = array();
$info['user_nicename'] = $info['nickname'] = $info['display_name'] = $info['first_name'] = $info['user_login'] = sanitize_user( $_POST['register_username'] ) ;
$info['user_pass'] = $_POST['register_password'];
$info['user_email'] = sanitize_email( $_POST['register_email'] );
// Register the user
$user_register = wp_insert_user( $info );
if ( is_wp_error( $user_register ) ) {
$error = $user_register->get_error_codes() ;
if ( in_array( 'empty_user_login', $error ) ) {
echo json_encode( array (
'success' => false,
'message' => __( $user_register->get_error_message( 'empty_user_login' ) )
) );
} elseif ( in_array ( 'existing_user_login', $error ) ) {
echo json_encode ( array (
'success' => false,
'message' => __( 'This username already exists.', 'inspiry' )
) );
} elseif ( in_array ( 'existing_user_email', $error ) ) {
echo json_encode( array (
'success' => false,
'message' => __( 'This email is already registered.', 'inspiry' )
) );
}
} else {
//send password as part of email to newly registered user
inspiry_new_user_notification( $user_register, $info[ 'user_pass' ] );
echo json_encode( array(
'success' => true,
'message' => __( '', 'inspiry' ),
) );
}
die();
}
// Enable the user with no privileges to request ajax register
add_action( 'wp_ajax_nopriv_inspiry_ajax_register', 'inspiry_ajax_register' );
endif;
im adding password input in registration form and use $_POST['register_password'] but not worked! is there more template part i must change it? can you tell me what is the wrong? sorry for my bad en language and thanks in advance!