почему параметр читается как true? - PullRequest
0 голосов
/ 10 марта 2020

Я пытался вызвать переменную $ hetest, но она всегда возвращает значение true, однако я добавляю false в качестве параметра при вызове функции

 //function which i call in javascript file
         create_new_user_send_sms(user_Mobile_Number,false)
                              .fail(error => console.error(error))
                              .done(response => {})
   //the ajax call of the function i created 
      function create_new_user_send_sms(mobile_number,hestatus){
            return jQuery.ajax({
              type : "POST",     
              url: ajax_object.ajax_url,
              data: {    
                action : 'create_user_send_sms',     
                mobile_number : mobile_number,
                auto_Login_status : "true",
                he : hestatus,
              },

              success: function (data) {  
              },

              error : function(error){
                  console.log("error:" + error);
              }
           });
        }

//the code in the php function create_user_send_sms
 $mobile_number = $_POST['mobile_number'];
  $auto_Login_status = $_POST['auto_Login_status'];
  $hetest = $_POST['he']; 
  $password = wp_generate_password( 4, false, false );

1 Ответ

1 голос
/ 10 марта 2020

Попробуйте использовать функцию filter_validation для обработки логических переменных:

$hetest = filter_var ($_POST['he'], FILTER_VALIDATE_BOOLEAN);

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...