admin管理员组

文章数量:1417408

I wish to ask how to build a real time control while a user attempt to register his website in a wordpress multisite installation. The control should check if the subdomain already exists while the user is typing it into the input field.

This control will involve a simple jquery function, executed while typing, that check all the existing subdomain in the wordpress database table.

Any suggestion would be appreciated. Thank you very much.

I wish to ask how to build a real time control while a user attempt to register his website in a wordpress multisite installation. The control should check if the subdomain already exists while the user is typing it into the input field.

This control will involve a simple jquery function, executed while typing, that check all the existing subdomain in the wordpress database table.

Any suggestion would be appreciated. Thank you very much.

Share Improve this question asked Sep 21, 2013 at 17:09 VirgoVirgo 991 silver badge10 bronze badges 3
  • Do you need the js or the php side? – Dan Ștefancu Commented Sep 21, 2013 at 17:15
  • I need js and php code. If searching on google it's not difficult to find, understand and implement js code. a little bit different is for php code. thank you very much. – Virgo Commented Sep 21, 2013 at 17:24
  • 1 You can start something from here. – brasofilo Commented Sep 21, 2013 at 20:03
Add a comment  | 

1 Answer 1

Reset to default 0

Searching on google I found this jquery script that, maybe, could be a starting point. But to tell the true, I don't know exactly how to connect this to the wp-signup.php file.

If I'm not in worng. The jquery function is executed on 'keyup' and check the data returned from the "scripts/db_check_url". What I'm missing is this "scripts/db_check_url" that will perform the database search.

Any suggestions? Thank you very much.

// css styles
//
<style>
.error {background-image:url('error.jpg');}
.success {background-image:url('success.jpg');}
</style>


//input textfield with an icon check
//
<input class="subdomain" type="text" value="" name="url">
<div id="icon-message" class="error"></div>

//jquery function
//
(function($){
    $(document).ready(function(){
        $('input[name="url"]').on('keyup',function(){
         var val=$(this).val();
         $.post(scripts/db_check_url',{url:val},function(data){
            if(!data.error){
              $('#icon-message').removeClass('error').addClass('success');
            }else{
              $('#icon-message').removeClass('success').addClass('error');
             }
         },'json');});
    $('input[name="url"]').trigger('keyup');});
})(window.jQuery);

本文标签: jquerymultisite registration check existing subdomains while typing