$conf, $runtime; function_exists('chdir') AND chdir(APP_PATH); $r = 'mysql' == $conf['cache']['type'] ? website_set('runtime', $runtime) : cache_set('runtime', $runtime); } function runtime_truncate() { global $conf; 'mysql' == $conf['cache']['type'] ? website_set('runtime', '') : cache_delete('runtime'); } register_shutdown_function('runtime_save'); ?>plugin development - Wordpress Ajax not returning Response|Programmer puzzle solving
最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

plugin development - Wordpress Ajax not returning Response

matteradmin9PV0评论

I have an ajax call which is working perfectly but is not returning any response below is how i registered my scripts

    wp_enqueue_script('wcp-signup-custom-js', WCP_PLUGIN_URL . '/WCP/FrontEnd/Signup/js/wcp_signup_script.js');


    wp_localize_script( 'wcp-signup-custom-js', 'settings', ['site_url'=> site_url("/") ,'ajax_url' => admin_url( 'admin-ajax.php' ) ]  );

jquery code

 $.ajax({
               // url: ajaxurl,
                url: settings.ajax_url,
                method: "POST",
           //     contentType: "application/json",
                //  action: "wcp_signup",
                dataType: "json",
                // data: fdata
                data: formData,
                success: function (response) {
                    console.log(response);
                }    });

and below is the function being executed

 public function wcp_do_signup()
{
      global $wpdb;
        $first_name = $_REQUEST['input_first_name'];
        $last_name = isset($_REQUEST["input_last_name"]) ? $_REQUEST["input_last_name"] : "";
        $full_name = $first_name . " " . $last_name;
        $full_name = trim($full_name);

        $email = $_REQUEST['input_email'];
        $pass = $_REQUEST['input_pass'];
      $new_user_id = wp_create_user($email, $pass, $email);


            update_user_meta($new_user_id, "first_name", $first_name);
            update_user_meta($new_user_id, "last_name", $last_name);

            if ($new_user_id){

                //Do Login
                wp_set_current_user($new_user_id, $email);
                wp_set_auth_cookie($new_user_id);
                do_action('wp_login', $email);

                $url = site_url() . "/school-dashboard";
                $user = get_userdata($new_user_id);

                $response = array('status' => 'ok', 'msg' => 'Registered successfully. Please wait...', 'url' => $url); }else{
                                  $response = array('status' => 'no', 'error' => 'Registration problem. Please contact administrator.'); }
    echo json_encode($response);
    die();

}

The user is being created but I am receiving this is in chrome Network Tab

And in console i am recieving this

Post a comment

comment list (0)

  1. No comments so far