I've got a field like this...
<input type="text" name="summary" value="" required />
...which I am easily able to sanitize_text_field and add_post_meta with this...
$summary = sanitize_text_field($_POST["summary"]);
add_post_meta( $post_id, 'summary', $summary);
But when it comes to the additional post_meta I need to store in the DB, I don't know how to go about it because I don't know how many additional fields there will be in the form. It will vary.
So the additional form fields could be like this...
<input type="text" name="cat_01" value="" />
<input type="number" name="dog_01" value="" />
<input type="number" name="rabbit_01" value="" />
<input type="text" name="mouse_01" value="" />
<input type="text" name="cat_02" value="" />
<input type="number" name="dog_02" value="" />
<input type="number" name="rabbit_02" value="" />
<input type="text" name="mouse_02" value="" />
...but sometimes there could be a 3rd set of these fields, or a fourth etc and there's really no limit, and I don't know how many sets of these fields there will be.
So for example if there is a 3rd set of these fields they will look like:
<input type="text" name="cat_03" value="" />
<input type="number" name="dog_03" value="" />
<input type="number" name="rabbit_03" value="" />
<input type="text" name="mouse_03" value="" />
So you get the idea.
How can I sanitise and add_post_meta when I don't know what I'm going to be capturing?
Cheers.