Create a login script for WordPress

Last Updated: January 28, 2019

  time(),
        'user_email'  =>  $email_address,
        'first_name'  =>  $first_name,
        'last_name'  => $last_name,
        'user_pass'   =>  $password  // When creating an user, `user_pass` is expected.
    );
    
    $user_id = wp_insert_user( $user_data ) ;
    update_user_meta($user_id, 'subscribe_status', $subscribe_status);
    
    //On Success
    if ( ! is_wp_error( $user_id ) ) {
        $response['status'] = 'success';
        wp_set_auth_cookie($user_id);
    }else{
        $response['status'] = 'failed';
    }
    
endif;

Add your feedback or comment below: