So, I have a few form fields like so:
<input name="mainStageSatOrder[theband][theid]" type="hidden" class="band-id" value="" />";
<input name="mainStageSatOrder[theband][theorder]" type="hidden" class="band-order" value="" />";
As you can see, these form fields (of which there are more, these are just examples of both types) create a multi-dimensional array like so (I hope, please correct me if I’m wrong):
Array (
[mainStageSatOrder] => Array
(
[theband] => Array
(
[theid] => 1
[theorder] => 5
)
[theband] => Array
(
[theid] => 2
[theorder] => 8
)
)
)
I want these values to use the update_post_meta function to update the relevant fields when the page update is submitted. I know I can hook into the submit action post_submitbox_start action which I understand just fine.
What I’m not sure on, is what the PHP might be once the submit button is clicked. What I want to happen is that when the submit button is clicked, the multidimensional array is looped through using a foreach loop and for each ‘theband’ sub-array, the two values are used in the update_post_meta function.
foreach(???) {
update_post_meta( 1, 'theorder', '5' ); //where 1 and 5 are values passed from the MD array
}
So, the process goes:
1) User clicks publish/update button
2) All values from all fields are passed into the multidimensional array
3) The MD array is looped through and, using update_post_meta, the relavent data is updated
4) Confirm yes/no
Thanks.