I am trying to get the user input into a Wordpress query array. I can get the input with my jquery code but i want to add it to the 'meta_value' => '123456', in the php array. How can i change the'meta_value' => '123456', from '123456' to the var x from the jquery script?
If this is not possible can someone suggest another way to get the 'meta_value' => '123456', from an input field?
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery("#bt").click(function(){
var x = jQuery("#txt_name").val();
alert(x);
});
});
</script>
<input type="text" id="txt_name" />
<input type="button" id="bt" value="click here" />
<?php
$args = array(
'meta_key' => 'cardnum',
'meta_value' => '123456',
'meta_compare' => '='
);
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '<p>' . $user->cardnum ." ". $user->nickname . '</p>';
}
} else {
echo 'Not available number.';
}
?>