Support

Account

Home Forums Backend Issues (wp-admin) Run function in acf/validate_save_post Reply To: Run function in acf/validate_save_post

  • 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;
      }