Hello,
I’ve been having the same problem on WP 4.4.2, thus I got the plugin finally working and I think the main problem is with the admin_footer
hook used.
Anyway change the username_check.php
file in the plugin directory to the following:
add_action('wp_head', 'usercheck');
function usercheck() {
?>
<script type="text/javascript" >
var xhr = 0;
jQuery(document).ready(function ($) {
$('#user_login, input[name="user_login"]')
.after('<span class="uc_disp" id="uc_ajax_loader">'
+ '<img src="<?php echo plugin_dir_url(__FILE__) . 'ajax-loader.gif'; ?>" width=16 height=16 title="Loading..."/></span>')
.after('<span class="uc_disp" id="uc_valid">'
+ '<img src="<?php echo plugin_dir_url(__FILE__) . 'valid.png'; ?>" width=16 height=16 title="Valid"/></span>')
.after('<span class="uc_disp" id="uc_invalid">'
+ '<img src="<?php echo plugin_dir_url(__FILE__) . 'invalid.png'; ?>" width=16 height=16 title="Invalid"/></span>')
$('.uc_disp').hide();
$('#user_login').bind('keyup change', function () {
var data = {
action: 'check_username',
username: $('#user_login').val(),
};
$('.uc_disp').hide();
$('#uc_ajax_loader').show();
if (xhr)
xhr.abort();
xhr = $.ajax({
url: ajaxurl,
type: 'get',
async: true,
data: data,
success: function (response) {
$('.uc_disp').hide();
if (response == 0) {
$('#uc_valid').show();
$('input[type="submit"]').removeClass("disabled");
$('input[type="submit"]').prop("disabled", false);
} else {
$('#uc_invalid').show();
$('input[type="submit"]').addClass("disabled");
$('input[type="submit"]').prop("disabled", true);
$('input[type="submit"]').attr("title", "the username entered is not available");
}
;
},
});
});
});
</script>
<?php
}
//echo 0 si n'existe pas
add_action('wp_ajax_check_username', function() {
if (username_exists($_GET['username']) == null)
echo 0;
else
echo 1;
die();
});
This will also work on Woocommerce username field in the registration form (I double checked).
In addition I added a disabled attribute, a disabled class, an info title to the register button whenever an unavailable username is chosen.
I hope that helps and best of luck,
Cheers!