Okej, I’m added hidden field where i add post_id
and i get this id – $_POST[‘acf’][‘field_5e89d88ead452’]
Okej, I’m added hidden field where i add post_id
and i get this id – $_POST[‘acf’][‘field_5e89d88ead452’]
I used the wrong filter…
but I have one more problem. How to get post id of saved post in this action?
$_POST[‘ID’] – it does not work.
add_action('acf/validate_value/key=field_5e85a3ad796cf', [$this, 'acfValidateCode'], 10, 4);
public function acfValidateCode($valid, $value, $field, $input_name)
{
if( $valid !== true ) {
return $valid;
}
$results = apply_filters('check_promo_code', $value);
if ($results && $results[0]->post_id != $_POST['ID']) {
$valid = 'Taki kod promocyjny już instnieje.';
}
return $valid;
}