foreach in wordpress form does not work

0

I am sending an email, using the native wordpress function wp_mail where I send several fields concatenated in the $message variable, including user-marked checkboxes. Although it is believed to be doing right, these checkboxes are the only ones that point to errors and are not sent, appearing the error:

Warning: Invalid argument supplied for foreach() in functions.php line 92

where this line has the following

foreach ( $_POST['salgados_selecionados'] as $key => $value ) {
   $message .= $value;
}

checkboxes are several, but an example would be

<input type="checkbox" name="salgados_selecionados" id="232" value="Bolinha com carne seca">
<input type="checkbox" name="salgados_selecionados" id="258" value="Bolinha de queijo">
<input type="checkbox" name="salgados_selecionados" id="256" value="Coxinha">

I used this same idea in another project and it worked.

    
asked by anonymous 22.05.2018 / 00:21

0 answers