Есть вот такой скрипт.
jQuery(document).ready(function ($) {
// Perform AJAX login/register on form submit
jQuery('#myavatar').on('submit', function (e) {
if (!jQuery(this).valid()) return false;
jQuery('p.status', this).show().html(ajax_profile_object.loadingmessage);
action = 'ajaxavatar';
ctrl = jQuery(this);
$.ajax({
type: 'POST',
dataType: 'json',
url: ajax_profile_object.ajaxurl,
data: {
'action': action,
},
success: function (data) {
jQuery('p.status', ctrl).text(data.message);
if (data.loggedin == true) {
var delay = 3000;
setTimeout("document.location.href = ajax_profile_object.redirecturl", delay);
}
}
},3000);
e.preventDefault();
});
});
И функция
function ajax_profile_init(){
wp_register_script('ajax-profile-script', get_template_directory_uri() . '/js/js/ajax-profile-script.js', array('jquery') );
wp_enqueue_script('ajax-profile-script');
wp_localize_script( 'ajax-profile-script', 'ajax_profile_object', array(
'ajaxurl' => admin_url( 'admin-ajax.php' ),
'redirecturl' => home_url(),
'loadingmessage' => __('<img id="imgcode" src="http://########.com/loading.gif" alt="Sending user info, please wait...">')
));
// Enable the user with no privileges to run ajax_login() in AJAX
add_action( 'wp_ajax_nopriv_ajaxavatar', 'my_avatar' );
}
function my_avatar(){
echo json_encode(array('loggedin'=>false, 'message'=>__('Invalid username or e-mail.')));
die();
}
loadingmessage подгружается, а вот my_avatar не срабатывает....