I am trying to verify some form with Wordpress and jQuery Validate plugin. My JS code is:
  & lt; Script type = "text / javascript" & gt; Var ajaxurl = "& lt ;? php echo admin_url ('admin-ajax.php') ;? & gt;"; // reg-form jQuery (document) .ready (function ($) {$ .ajaxSetup ({cache: false}); $ ( "# username") submitted to. Change (function () {$ ( "# User name ") .removeData (" previousValue ");}); $ (" # moto_register ") validate ({ignore:" "rule: {username: {Remote: {url: ajaxurl, type:" POST " data: {username: function () {return $ ( "#username") .val ();}, verb: 'moto_validate_username'}}}}, submitted Handler: function (form) {var sData = $ (form) .serialize (); $ .ajax ({url: Ajaxel, async: wrong, type: 'post', data: sdata, success: function (Data) {if (console.log) console.log (data); Location.href = "http://test.net/?page_id=30"}});}});   I have the following code plugin I:
  function moto_validate_username () {$ user_id = username_exists ($ _POST [ 'username']); if (! $ User_id) ' true 'echo; Else echo' false '; Exit ();} Add_action (' wp_ajax_novriv_moto_validate_username ',' moto_validate_username '); Add_action (' wp_ajax_moto_validate_username ',' moto_validate_username ');   It only works a few times, and sometimes it does not happen that AJX seems to have actually been removed, but there is no response, and therefore there is no verification. . Why does anyone have an idea?
 You must avoid the  admin_init  hook to remove  menu_pages < / Em> and  submenu_pages , because it could create conflicts with AJAX (see). Join 
  admin_menu  instead of hook. If you have trouble deleting  some  of pages, then bind to a very high priority such as 120 Priority to remove  theme-editor.php  Need to be fixed. For Jetpack pages, you need about 2000. 
  add_action ('admin_menu', 'Moto_remove_menu_pages', 2000);   It has also been said.
Comments
Post a Comment