Home Forums Backend Issues (wp-admin) Check if value already exist 2 Reply To: Check if value already exist 2

  • That’s exactly what I’m looking for – thanks.

    But is it possible to combine two or more fields?

    So if Field A has value ‘x’ and Field B value ‘y’, there must not be another combination of these two fields with these values.

    My code looks like this, but it doesn’t work:

    add_filter('acf/validate_value/name=strasse', 'validate_lien_video_filter', 10, 4);
    function validate_lien_video_filter($valid, $value, $field, $input) {
        $post_id_field_key = 'field_58ac5c77d3d6e';
      if (!$valid || $value == '' || !isset($_POST['acf'][$post_id_field_key])) {
        return $valid;
        // change the field key below to the field key for your 
        // hide_post_id_field field
        $post_id = $_POST['acf'][$post_id_field_key];
      global $post; 
      $id = $post->ID;
      $plz = get_field('plz', $id);
      $location = get_field('ort', $id);
      $args = array(
        'post__not_in' => array($post_id), // do not check this post
        'meta_query' => array(
          'relation' => 'AND',
            'key' => 'strasse',
            'value' => $value
            'key' => 'plz',
            'value' => $plz
            'key' => 'ort',
            'value' => $location
      $query = new WP_Query($args);
      if (count($query->posts)) {
        // found at least one post that
        // already has $value
        $valid = 'There is already a post using this video';
      return $valid;

    Do you have a hint for me to solve this problem? Thank you so much! Really great support!