I need help for a little problem with my custom metabox in WordPress.
I have a table with a group of 3 values per row. Number of row is undefined, because users can add or remove one of them.
I need to save each row (so 3 values in 3 inputs) in a specific array.
For this source code, i removed voluntarily all the system which is add a row, delete a row etc… I also remove all the query/variable tests.
I think this problem isn’t difficult to solve, but i don’t see any solution..
Thanks!
function my_meta($post){
$get_values = get_post_meta($post->ID,'_MY_META_ROW',false);
echo '<table>';
foreach($get_values as $v => $MY_META_ROW){
echo '<tr>
<td><input type="text" name="MY_INPUT_1" value="'.$MY_META_ROW['INPUT_1'].'" /></td>
<td><input type="text" name="MY_INPUT_2" value="'.$MY_META_ROW['INPUT_2']'" /></td>
<td><input type="text" name="MY_INPUT_3" value="'.$MY_META_ROW['INPUT_3'].'" /></td>
</tr>';
}
echo '</table>';
}
add_action('save_post','save_my_inputs');
function save_my_inputs($post_id){
foreach($_POST['??????????'] as $value){
$array_row = array (
"MY_INPUT_1" => $POST['MY_INPUT_1'];
"MY_INPUT_2" => $POST['MY_INPUT_2'];
"MY_INPUT_3" => $POST['MY_INPUT_3'];
)
add_post_meta($post_id, '_MY_META_ROW', $value);
}
}