I'm building a website in wordpress, and I need to make a login page & register page / popup with ajax + account page with some custom fields that I need to put thier like adress, phone number, etc...

I want to make that without any plugins - Can someone give me a tutorial or small explaination how to make it? how to start?

PS - I know PHP SQL in high level - without wordpress I would build that easily, I just need a small help how to make that in wordpress system

Thanks for all :)

  • Here's someone that had a similar question - they basically wanted to custom style the WordPress default screens (like login & register) - you can do all of this with custom templates directly in your theme: wordpress.stackexchange.com/questions/365154/… May 17, 2020 at 22:19

2 Answers 2


I am doing the same thing at the moment and I just use the standard WP login/register systems/pages.

You can use wp_signon() to do logon.

Then on a standard page, you can create a custom template and use this for retrieving their info: wp_get_current_user()

You will also need to get the customer user meta information you store too using: get_user_meta()

Hope that helps you :)


for find out and init actions

if (!is_user_logged_in()) {
    add_action('init', 'ajax_login_init');
} else {
    add_action('init', 'ajax_logout_init');
function ajax_login_init()
    add_action('wp_ajax_nopriv_ajax_login', 'ajax_login');
    add_action('wp_ajax_nopriv_ajax_register', 'ajax_register');
function ajax_logout_init()
    add_action('wp_ajax_ajax_logout', 'ajax_logout');

login function

function ajax_login()
    check_ajax_referer('ajax-login-nonce', 'security');
    $info = array();
    $info['user_login'] = $_POST['login_username'];
    $info['user_password'] = $_POST['login_password'];
    $info['remember'] = $_POST['remember'];

    $user_signon = wp_signon($info, false);
    if (is_wp_error($user_signon)) {
        wp_send_json(array('status' => 0, 'message' => $user_signon->get_error_message()));
    } else {
        wp_send_json(array('status' => 1, 'message' => __('you currectly logined')));;

register function

function ajax_register()
    check_ajax_referer('ajax-register-nonce', 'security');
    // Post values
    $username = sanitize_text_field($_POST['register_username']);
    $password = sanitize_text_field($_POST['register_password']);
    $email = sanitize_text_field($_POST['register_email']);
    $name = sanitize_text_field($_POST['register_name']);
    $nick = sanitize_text_field($_POST['register_name']);

    $userdata = array(
        'user_login' => $username,
        'user_pass' => $password,
        'user_password' => $password,
        'user_email' => $email,
        'first_name' => $name,
        'nickname' => $nick,

    $user_id = wp_insert_user($userdata);

    // add user meta
    $custom_user_meta_value = 'custom_user_meta_value';
    add_user_meta( $user_id, 'custom_user_meta', $custom_user_meta_value);

    // Return
    if (!is_wp_error($user_id)) {
        $user_signon = wp_signon($userdata, false);
        if (!is_wp_error($user_signon)) {
            wp_send_json(array('status' => 2, 'message' => __('your registration is successfuled and logined.')));
        } else {
            wp_send_json(array('status' => 1, 'message' => __('your registration is successfuled and logined')));
    } else {
        wp_send_json(array('status' => 0, 'message' => __($user_id->get_error_message())));

logout function

function ajax_logout()
    check_ajax_referer('ajax-logout-nonce', 'ajaxsecurity');

    ob_clean(); // probably overkill for this, but good habit
    echo 'adios!!';

add_action('wp_logout', 'auto_redirect_after_logout');
function auto_redirect_after_logout()
  • You should try and explain the code you're providing. I know what all the functions you've supplied are supposed to do, but you haven't really explained anything to the user who specified that they don't know WP that well. May 17, 2020 at 22:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.