How to Create Registration Form in Wordpress Without Plugin?

How-to-Create-Registration-Form-in-Wordpress-Without-Plugin_.png
After a lot of study about Wordpress, we found the most asked question about Wordpress is: How to Create Registration Form in Wordpress Without Plugin? So the Answer we have explained below. Head over the code and show your talent. Yes, We can Create a Custom register form without using any plugin. Below I will tell you to step by step Example in details that I have already implemented in a WordPress website. First We need to Create a template for the register form: Let say tmpl-register.php is our file name: Now the form is ready. Please check for the id and proper classes. In this form i am using the Jquery validation. To use jquery you need to include the file jquery.validate.js. You can get this online by Search on google. you can add the jquery in your footer.php file or any new js file. I am using the validation in the footer.php file First we need to include the file And the code for Validation:

In the Above code you will see the id and the classes used for the proper validation. And you can change and add the new messages as per your requirements. Here you noticed i have given the url. url: '/template-parts/reg-ajax.php', So the New file would be reg-ajax.php. This file is used for Insert the new user to the database. Just follow the code you will understand. File name: reg-ajax.php. As you see i have given in the url template-parts/reg-ajax.php. That means i have put this file in the template-parts folder into my theme folder. you can place it outside the folder as you want with changing of your path name. reg-ajax.php
prefix."users";
$sel= "Select * from $table  where user_login= '".$email."'";
$posts = $wpdb->get_results($sel);
$rowCount = $wpdb->num_rows;

if($rowCount > 1 )
{
	echo 'user already exsits';
   
}else{
		 
		$default_newuser = array(
        'user_pass' => $pass,
        'user_login' => $email,
        'user_email' => $email,
        'first_name' => $fname,
		'last_name'     =>  $lname,
        'role' => 'seller'
        ); 
		
        $users = wp_insert_user( $default_newuser );
		
		if ( ! is_wp_error( $users ) ) {
			echo 'Registration complete.  Go to login page.';  
		}
		
		else{
			echo "User Already Exists. Please try with another Email Address.";
			
		}
		
       
	
    }

?>
I have placed all three files in the template-parts folder. In this Twenty-sixteen theme used. You can use in any theme. the code will work just use the proper id and remember to include the jquery as well. You can add more fields and validation according to the requirements. If you'd like to see how to create landing pages and sales funnels with WordPress? You can click here to learn more. If you have more question go Comments below. We would love to hear from you, Enjoy.