First I change:
$_POST['fields'][...
to $_POST['acf'][...
Second:
if( $post_id != 'new' )
->if( $post_id != 'new_post' )
Now I have only two problem.
First: When I create a new project, I will look for the start and end of a project. In the past I got a feedback when the end date was before the start date. Now nothing happen.
Under “Projekt einreichen” you will find what I mean (this is ACF V4, but I am testing on V5 for the future)
Projektbörse
I control the div #acf-sdate
and #acf-adate
with a javascript:
jQuery(document).ready(function($) {
//Abschluss
$('#acf-adate > div input').change(
function () {
var datumStart = $('#acf-sdate > div > input').val();
var datumAbschluss = $('#acf-adate > div > input').val();
if (datumStart){
if (datumStart > datumAbschluss) {
$('#acf-adate > div > input').val('');
$('#acf-adate').addClass('error');
} else if ($('#acf-adate').hasClass('error')) {
$('#acf-adate').removeClass('error');
}
}
}
);
//Start
$('#acf-sdate > div input').change(
function () {
var datumStart = $('#acf-sdate > div > input').val();
var datumAbschluss = $('#acf-adate > div > input').val();
if (datumAbschluss){
if (datumStart > datumAbschluss) {
$('#acf-sdate > div > input').val('');
$('#acf-sdate').addClass('error');
} else if ($('#acf-sdate').hasClass('error')) {
$('#acf-sdate').removeClass('error');
}
}
}
);
}
);
Second: Everytime I push a project, I push two posts. One in projects-all and one in posts:
<?php acf_form(array(
'post_id'=> 'new_post',
'field_groups' => array ( 1098 ),
'return' => home_url('thank-you'),
'submit_value'=> 'Projekt einreichen'
)); ?>