This is my script for the update of the fields on my custom taxonomy, i know that the code for the field upload is wrong but i can’t find a solution to upload a file for that field. Really need some help on that one to work with my actual code.
if(isset($_POST[‘submitted’]) && isset($_POST[‘post_nonce_field’]) && wp_verify_nonce($_POST[‘post_nonce_field’], ‘post_nonce’)) {
$new_post = array(
‘post_title’ => esc_attr(strip_tags($title)),
// ‘post_content’ => esc_attr(strip_tags($description)),
‘post_type’ => ‘proiecte’,
‘post_status’ => ‘publish’,
‘tax_input’ => array(
‘categorie’ => array(17)
),
);
$post_id = wp_insert_post($new_post);
$att = my_update_attachment(‘postIMG’, $post_id);
$fields = array(
‘field_5aeda3aee788b’ => $_POST[‘postAuthor’],
‘field_5aedb0ec1d441’ => $_POST[‘postJob’],
‘field_5aedbf6b4ba92’ => $_POST[‘postTeam’],
‘field_5aedbf814ba93’ => $_POST[‘postOffice’],
‘field_5aedbf8f4ba94’ => $_POST[‘postContributors’],
‘field_5aedbf984ba95’ => $_POST[‘postContributorsOut’],
‘field_5aedbfa14ba96’ => $_POST[‘postLocation’],
‘field_5aedbfa94ba97’ => $_POST[‘postClient’],
‘field_5aedbfb04ba98’ => $_POST[‘postBudget’],
‘field_5aedbfb94ba99’ => $_POST[‘postConstructionArea’],
‘field_5aedbff54ba9a’ => $_POST[‘postAddress’],
‘field_5aedc00e4ba9b’ => $_POST[‘postEmail’],
‘field_5aedc0164ba9c’ => $_POST[‘postPhone’],
‘field_5aedc01d4ba9d’ => $_POST[‘postCNP’],
‘field_5aedc0284ba9e’ => $_POST[‘postCIL’],
‘field_5aedc62b84d17’ => $att[‘attach_id’]
);
print_r($att[‘attach_id’]);
for ($i=0; $i < count($fields); $i++) {
update_field(array_keys($fields)[$i], array_values($fields)[$i], $post_id );
}
if($post_id)
{
echo ‘<div class=”form-popup”><span>Thank you !</span></div>’;
}
}