mardi 28 juin 2016

admin-ajax.php 404 Not Found - Wordpress and Buddypress

I'm using Buddypress and getting a 404 on admin-ajax.php when trying to log in on a front-end form. I followed this tutorial to make the ajax forms: http://ift.tt/JnfhqG

If you try to log in nothing happens, but if you refresh the page you are actually logged in. You should be redirected to the homepage once logged in. The same thing happens on the sign up form. An ajax request is sent when a username is inputted to check if it's in use or not.

This used to work perfectly and then suddenly stopped, on either a wp or bp update. I can't find any info on this particular problem anywhere.

If I deactivate Buddypress, this problem goes away.

Login page: http://ift.tt/291aXdt Try any old username and password to get the 404 in console.

My login function looks like this

function ajax_login_init(){

    wp_register_script('ajax-login-script', get_template_directory_uri() . '/scripts/ajax-login-script.js', array('jquery') ); 
    wp_enqueue_script('ajax-login-script');

    wp_localize_script( 'ajax-login-script', 'ajax_login_object', array( 
        'ajaxurl' => admin_url( 'admin-ajax.php' ),
        'redirecturl' => home_url(),
        'loadingmessage' => __('Sending user info, please wait...')
    ));

    // Enable the user with no privileges to run ajax_login() in AJAX
    add_action( 'wp_ajax_nopriv_ajaxlogin', 'ajax_login' ); }

    add_action('init', 'ajax_login_init') ;

I've tried using an abosulte link in place of admin_url( 'admin-ajax.php' ), and even copying the admin-ajax file elsewhere, and nothing is working. This problem occurs both on my localhost and the live site.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire