I have a hidden field in Wordpress
<input name='af_field[]' class='temp_cls1' type='hidden' value='<?php echo $param[0] . ":" . $param[1] . ":" . $param[2]; ?>'/>
How can i sanitize and escape the hidden field?
I have a hidden field in Wordpress
<input name='af_field[]' class='temp_cls1' type='hidden' value='<?php echo $param[0] . ":" . $param[1] . ":" . $param[2]; ?>'/>
How can i sanitize and escape the hidden field?
based on the information given..
You deal with hidden fields exactly the same way as visible fields, the $_POST
supervariable will contain the information.
so one way of doing this is:
$hidden_var= sanitize_text_field($_POST[af_field][0]); // note you are passing a array of values so do a foreach if there are a few values.
then in your form:
<input name='af_field[]' class='temp_cls1' type='hidden' value='<?php echo esc_attr($param[0]) . ":" . esc_attr($param[1]) . ":" . esc_attr($param[2]); ?>'/>