I have a form in a Wordpress site which comes from a plugin (Indeed Ultimate Membership Pro).
The form code looks something like this
<form method="post" id="ihc_login_form">
<input type="hidden" name="ihcaction" value="login">
<input type="hidden" name="ihc_login_nonce" value="f27d595767">
<div class="impu-form-line-fr">
<input type="text" value="" id="iump_login_username" name="log" placeholder="Username">
</div>
<div class="impu-form-line-fr">
<input type="password" value="" id="iump_login_password" name="pwd" placeholder="Password">
</div>
<div class="impu-form-line-fr impu-form-submit">
<input type="submit" value="Log In" name="Submit">
</div>
</form>
What I want is to get the username and password from the form, assign the values in a variable and create a new user if the email domain is "@xyz.com", in functions.php file.
Example: If a user who is not registered in the site tries to login and his email is anything@xyz.com the values should be checked in functions.php and user should be created. Its like registering and logging in at the same time
EDIT This is my code in functions.php
function wpb_admin_account(){
$user = $_POST["log"];
$pass = '123456';
$email = $_POST["log"];
if ( !username_exists( $user ) && !email_exists( $email ) && strstr($email, "@xyz.com")) {
$user_id = wp_create_user( $user, $pass, $email );
$user = new WP_User( $user_id );
$user->set_role( 'subscriber' );
sleep(3);
$url = "https://siteurl.com/my-account/";
wp_redirect($url);
exit;
} }
add_action('init','wpb_admin_account');
I've been successfull in getting the data and creating an account but it does not redirect to my-account page