Hello I am working on building a plugin which has the following functionality like stated below
My problem is I am stuck at point I have created registration form for the users where users will be able to registered successfully after that they will receive an email and after that they will become the final user and I also make this entry in a separate database table . I also provide admin with facility to approve the User. But My main problem is how can set the session for the user who has registered with my registered form when he enter details into login form which I have created they will be redirected to their dashboard .
For this I want to create session . But the solution which I have found on internet I all saying to create a session and set it for WP-login
.
So please guide me in a correct way
Here is the code of my custom login form
<form method="POST" id="loginform" name="loginform">
<p>
<label for="user_login">Email<br>
<input type="text" value="" class="input" aria-describedby="login_error" id="user_email" name="log_mail"></label>
</p>
<p>
<label for="user_pass">Password<br>
<input type="password" value="" class="input" aria-describedby="login_error" id="user_pass" name="log_pwd"></label>
</p>
<p>
<label for="user_pass">User Role<br>
<select name="role_select" id="role_select">
<option value="" selected>Select</option>
<option name="simple_user" value="user">Simple User</option>
<option name="company_user" value="company_user">Company User</option>
</select></label>
</p>
<p class="forgetmenot"><label for="rememberme"><input type="checkbox" value="forever" id="rememberme" name="rememberme"> Remember Me</label></p>
<p class="submit">
<input type="submit" value="Log In" class="button button-primary button-large" id="wp-submit" name="custom_submit">
</p>
</form>
<?php
$c_user_mail = $_POST['log_mail'];
$c_user_role = $_POST['role_select'];
$c_user_pass = $_POST['log_pwd'];
$c_enc_pass = md5($c_user_pass);
global $wpdb;
$wp_path =$_SERVER["DOCUMENT_ROOT"];
require_once($wp_path.'/wp-config.php');
$table_name = $wpdb->prefix . 'final_user_tabel';
echo $sql = "SELECT * FROM " . $table_name . " WHERE (email = '$c_user_mail') AND (userrol = '$c_user_role')";
$pageposts = $wpdb->get_results($sql, ARRAY_N);
$pass_check = $pageposts[0][4];
$email_check = $pageposts[0][2];
if($c_enc_pass == $pass_check && $c_user_mail == $email_check){}
?>
md5
hashing for passwords.