Support

Account

Forum Replies Created

  • Thank you for your answer. Now I also use the save_post action but I insert a new field and update the value of this field with a combination of the two other ones. In the query I use the value of the compare field and it’s working fine.

  • For a post there exists the standard tag box from WordPress. And now I want to show this tag box in the frontend while creating a new post with acf_form(). But I don’t know how..

  • I try a better explanasion:

    I’ve got a field group for my categories. But these fields are only visible in the backend of WordPress.

    If I go to the backend -> posts -> categories you can find in the right top corner a search field for the categories.

    And my question is, if there’s a plugin or some code where I can search through my category fields with thie search field.

  • 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',
          array(
            'key' => 'strasse',
            'value' => $value
          ),
          array(
            'key' => 'plz',
            'value' => $plz
          ),
          array(
            '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!

  • Thank you, John.

    Here’s my code. Maybe it’s not perfect, but it works and perhaps it will help someone else.

    <?php $tabs = acf_get_fields(27);
            for($l = 0; $l < sizeof($tabs); $l++) {
                $type = $tabs[$l]['type'];
                if($type == 'accordion') {
                    $start = $l;
                    $name = $tabs[$l]['label'];
                }
                if(($tabs[$l+1]['type'] == 'accordion') || ($l == sizeof($tabs) - 1)) {
                    $end = $l;
                    while($start <= $end) {
                        // Here you can do with the fields whatever you want
                        $start++;
                    }
            } ?> 

    Attention: I’m using the plugin Accordion Tab Field (https://de.wordpress.org/plugins/acf-accordion/) instead of the “normal” tabs. So you have to change the string ‘accordion’ to ‘tab’ for “normal” use.

  • Yeah this solved my question. 🙂 Thanks a lot!

  • Thanks for your answer. So I have to add a date field to my posts too to use the “key” in the meta query, am I right? Or is there are another solution without extra field for posts?

  • we changed the configuration of the product handling, so no more help needed – but thanks a lot so far. 🙂

  • Okay I will try it.

    I’ve got a Woocommerce shop. There the customers can register. There are also four different customer categories: A, B, C and D. If a customers has registered, the admin can choose (with the radio button field ‘kundentyp’) on the profile page which typ the customer will be.

    Then there are the normal product categories. In the backend on the category page the admin also can choose (with a radio button field called ‘kundenzugang’) which customer category is allowed to visit this category.

    Every product has a field, where the admin can choose if the product should be published or not. So if there’s a customer B and want to visit the category ‘test’ where he hasn’t got an access (because only D is allowed to) and this category includes a product where this “public field” is tiggered, he is able to see this product in the frontend. Otherwise this public field isn’t tiggered he isn’t able to that product.

    So I’ve created a function for my functions.php which should go through all posts and check if the user is allowed to see the products. If there are product’s he isn’t able to see, the id of this product is written in an array ($id_arr). After that the array is taken to the ‘post__not_in’ to exclude them from the query.

    But my function (see first post) will not work and I don’t know why..

    I hope it’s a better explanation. Thanks for your help. 🙂

  • Thanks for your answer.

    But the field ‘kundentyp’ (type: radio button / transl.: typ of customer) is used in user profile and ‘kundenzugang’ (type: radio button / transl.: access of customer) is used in the productcategories.

    Only the field ‘soll_das_produkt_offentlich_dargestellt_werden’ (type: true/false / transl.: should the product be published?) is a field in the post.

    So the query-method won’t be the right one, or am I wrong?

Viewing 10 posts - 1 through 10 (of 10 total)