In my website currently for every new registration. New registered user is receiving their credential i.e., username and password in there email.
I want to allow the user to set their password at the time of registration and after that an email verification link will sent to their email id.
Below is my code which i want to modify:
<form method="post" class="wp-user-form " id="wp_signup_form_' . $rand_id . '" enctype="multipart/form-data">
<div class="col-md-12 col-lg-12 col-sm-12 col-xs-12">';
$cs_opt_array = array(
'id' => '',
'std' => '',
'cust_id' => 'user_login_' . $rand_id,
'cust_name' => 'user_login' . $rand_id,
'classes' => 'form-control',
'extra_atr' => ' size="20" tabindex="101" placeholder="' . __('Username*', 'theme_domain') . '"',
'return' => true,
);
$output .= $cs_form_fields2->cs_form_text_render($cs_opt_array);
$output .= '</div>';
$output .=$cs_form_fields_frontend->cs_form_text_render(
array('name' => __('Email*', 'theme_domain'),
'id' => 'user_email' . $rand_id . '',
'classes' => 'col-md-12 col-lg-12 col-sm-12 col-xs-12',
'std' => '',
'description' => '',
'return' => true,
'hint' => ''
)
);
$output .=$cs_form_fields_frontend->cs_form_hidden_render(
array('name' => __('Post Type', 'theme_domain'),
'id' => 'user_role_type' . $rand_id . '',
'classes' => 'col-md-12 col-lg-12 col-sm-12 col-xs-12',
'std' => 'candidate',
'description' => '',
'return' => true,
'hint' => ''
)
);
if (is_user_logged_in()) {
$output .= '<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">';
$cs_opt_array = array(
'id' => '',
'std' => __('Create Account', 'theme_domain'),
'cust_id' => 'submitbtn' . $rand_id,
'cust_name' => 'user-submit',
'cust_type' => 'button',
'extra_atr' => ' tabindex="103" onclick="javascript:show_alert_msg(\'' . __("Please logout first then try to registration again", "theme_domain") . '\')"',
'classes' => 'cs-bgcolor user-submit acc-submit',
'return' => true,
);
$output .= $cs_form_fields2->cs_form_text_render($cs_opt_array);
$output .= '
<!--</div>-->
</div>';
} else {
$output .= '<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12">';
$cs_opt_array = array(
'id' => '',
'std' => __('Create Account', 'theme_domain'),
'cust_id' => 'submitbtn' . $rand_id,
'cust_name' => 'user-submit',
'cust_type' => 'button',
'extra_atr' => ' tabindex="103" onclick="javascript:cs_registration_validation(\'' . admin_url("admin-ajax.php") . '\',\'' . $rand_id . '\')"',
'classes' => 'cs-bgcolor user-submit acc-submit',
'return' => true,
);
$output .= $cs_form_fields2->cs_form_text_render($cs_opt_array);
$cs_opt_array = array(
'id' => '',
'std' => $role,
'cust_id' => 'login-role',
'cust_name' => 'role',
'cust_type' => 'hidden',
'return' => true,
);
$output .= $cs_form_fields2->cs_form_text_render($cs_opt_array);
$cs_opt_array = array(
'id' => '',
'std' => 'cs_registration_validation',
'cust_name' => 'action',
'cust_type' => 'hidden',
'return' => true,
);
$output .= $cs_form_fields2->cs_form_text_render($cs_opt_array);
$output .= '
</div>
';
}
$output .='
<div class="col-md-6 col-lg-6 col-sm-12 col-xs-12 login-section">
<i class="icon-user-add"></i> ' . __("Already have an account?", "theme_domain") . '
<a href="#" class="login-link-page">' . __('Login Now', 'theme_domain') . '</a>
</div>
</div>
</div>
<div id="result_' . $rand_id . '" class="status-message"><p class="status"></p></div>
</div>';
$output .='</form>';
$output .='</div>';
Below is the function currently i am using in my website
function mytheme_registration_save($user_id) {
if ( isset($_REQUEST['action']) && $_REQUEST['action'] == 'register' ) {
$random_password = wp_generate_password($length = 12, $include_standard_special_chars = false);
wp_set_password($random_password, $user_id);
$reg_user = get_user_by('ID', $user_id);
if ( isset($reg_user->roles) && (in_array('subscriber', $reg_user->roles) || in_array('editor', $reg_user->roles) || in_array('author', $reg_user->roles)) ) {
// Site owner email hook
do_action('theme_domain_new_user_notification_site_owner', $reg_user->data->user_login, $reg_user->data->user_email);
// normal user email hook
do_action('theme_domain_user_register', $reg_user, $random_password);
}
}
}
}