Support

Account

Forum Replies Created

  • I’m sure this will be of value to anyone using that plugin.

    Does it work with both ACF4 and 5?

    Have you thought about making this into a plugin?

  • Because the added fields are not added to the cache and the next time acf gets the fields the new field will be missing, so the cache for the field group’s fields needs to be cleared. Or at least that’s my understanding of it.

    Something similar can happen when you add a field group after getting the field groups… under some conditions. I have a couple of plugins that get all of the ACF field groups, and then adds new field groups based on the existing fields. In these plugins I need to manually clear the acf field group cache to get my new field groups to appear where they are supposed to.

  • You’re going to hate me, but… I have a test site that I keep around for testing WooCommerce stuff. It has

    – WP 4.3.1
    – ACF 5.3.2.2
    – WooCommerce 2.4.10

    and I installed WooCommerce – Store Exporter 1.8.3

    I’m not saying that it’s not going away when deactivating this plugin, but with just these 3 plugins I’m not seeing an issue.

    What other plugins do you each have installed on the site, there must be something else in common.

    (Also, just a side note, the store exporter is not compatible with ACF5, only ACF4. Meaning it won’t export custom fields created with ACF5.)

  • Does this happen for all field groups for all post type location rules or just some post type location rules?

  • Glad you got the problem worked out, sorry no one replied sooner.

    I do recall that there were some issues with an earlier version of ACF4 with WP4.3.1 but I was under the impression that the latest version available for 4 had corrected them.

    So what you’re saying is the Gallery add on for ACF4 is still having issues?

  • Looking at acf_the_content I don’t see any reason why you couldn’t do the same thing by using acf_the_content everywhere you have the_content in your above code. acf_the_content basically calls most of the same filters that the_content runs as far as I know.

  • The most likely cause of this is a JavaScript error. JS Errors in other plugins are the most likely cause because ACF is working fine. If you can’t figure out where the error is or see any errors try deactivating other plugins and switching to one one of the 20XX WP themes.

  • Tried it with acf4 and still not seeing it. Can you post the rest of the arguments used for creating this post type?

    Actually, I’ve seen this before with my own CPT in the past, but it was quite some time ago. I don’t remember if I figured it out or not.

    Also, do you have any other CTPs created? Do you have custom taxonomies?

  • I am still not able to recreate this problem. Have you tried deactivating other plugins and switching themes?

    I’m not the developer but there’s only a couple of reasons that think of for this happening.

    The first is that something is wrong with your installation of ACF.

    The second is that there is something that’s modifying the post content for acf field groups. The field group settings are stored as a JSON encoded string in the post content fields.

    The third reason is that there is a filter of function somewhere that’s messing with the operator value of the location rule.

  • While I understand what you’re doing, it’s not really a good idea to depend on ACF returning an array of rows. Over the years I’ve been using ACF I’ve seen it change back and forth in places. I’ve coded for an array only to have sites break after an update because it was not longer returning an array in that place.

    I’ll mark this for the developer to look at if he can. Since you marked this as the repeater add on I’m assuming you’re using ACF4, which isn’t really being updated except for bugs and changes to WP the make it required.

    Your best bet is to use have_rows and get_sub_field whenever dealing with repeaters. http://www.advancedcustomfields.com/resources/have_rows/

  • 
    
    add_filter(
      'acf/load_value/name=YOUR_FIELD_NAME_HERE',
      'remove_expired_events_form_YOUR_FIELD_NAME_HERE',
      10, 3 
    );
    function remove_expired_events_form_YOUR_FIELD_NAME_HERE($value, $post_id, $field) {
    	//return $value;
      if (!is_array($value) || !count($value)) {
        // bail early
        return $value;
      }
      $count = count($value);
      $now = time();
      for ($i=0; $i<$count; $i++) {
    		$post_type = get_post_type(intval($value[$i]));
        $expire = intval(get_post_meta(intval($value[$i]), '_end_ts', true));
        if ($post_type == 'event' && $expire < $now) {
          unset($value[$i]);
        }
      }
      return $value;
    }
    
  • okay, I had a duh moment, been working with get_option all day.

    
    add_filter(
      'acf/load_value/name=YOUR_FIELD_NAME_HERE',
      'remove_expired_events_form_YOUR_FIELD_NAME_HERE',
      10, 3 
    );
    function remove_expired_events_form_YOUR_FIELD_NAME_HERE($value, $post_id, $field) {
      if (!is_array($value) || !count($value)) {
        // bail early
        return $value;
      }
      $count = count($value);
      $now = time();
      for ($i=0; $i<$count; $i++) {
        // adjusted this line again, change 0 to true
        $expire = intval(get_post_meta(intval($value[$i]), '_end_ts', true));
        if ($expire < $now) {
          unset($value[$i]);
        }
      }
      return $value;
    }
    
  • Remove the first line of the function, it was for debugging, forgot to remove it.

    
    var_dump($value);
    
  • I tested it with a post type with the same slug and I’m not seeing this issue.

    What version of ACF are you using?
    Have you tried deactivating other plugins and switching themes to see if that clears it up?

  • I made an adjustment. It appears that the values in the array are strings at this point and they need to be integers.

    
    add_filter(
      'acf/load_value/name=YOUR_FIELD_NAME_HERE',
      'remove_expired_events_form_YOUR_FIELD_NAME_HERE',
      10, 3 
    );
    function remove_expired_events_form_YOUR_FIELD_NAME_HERE($value, $post_id, $field) {
      var_dump($value);
      if (!is_array($value) || !count($value)) {
        // bail early
        return $value;
      }
      $count = count($value);
      $now = time();
      for ($i=0; $i<$count; $i++) {
        // adjusted this line
        $expire = intval(get_post_meta(intval($value[$i]), '_end_ts', 0));
        if ($expire < $now) {
          unset($value[$i]);
        }
      }
      return $value;
    }
    
  • This plugin saves the end date in a custom field named ‘_end_ts’ which is a timestamp. Unfortunately, I don’t know of a safe way to filter this to your existing filter, but it is possible to filter the values saved in this field and to remove the unwanted relationships when loading the field value. This would have the added side benefit of automatically removing expired events the next time the post with the relationship field is edited, if you don’t want that then you can make it only happen in the front end

    
    add_filter(
      'acf/load_value/name=YOUR_FIELD_NAME_HERE',
      'remove_expired_events_form_YOUR_FIELD_NAME_HERE',
      10, 3 
    );
    function remove_expired_events_form_YOUR_FIELD_NAME_HERE($value, $post_id, $field) {
      // if you want to have this run in the admin
      // remove this check
      if (is_admin()) {
        return $value;
      }
      if (!is_array($value) || !count($value)) {
        // bail early, no related events
        return $value;
      }
      $count = count($value);
      $now = time();
      for ($i=0; $i<$count; $i++) {
        $expire = intval(get_post_meta($value[$i], '_end_ts', 0));
        if ($expire < $now) {
          unset($value[$i]);
        }
      }
      return $value;
    }
    

    Your other choice would be to create a WP pre_get_posts filter that could do the same thing. https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts. This would probably work faster but I’m not sure if there’d be any side effects.

    
    add_action('pre_get_posts', 'no_expired_events', 0);
    function no_expired_events($query) {
      if (is_admin()) {
        return;
      }
      if ($query->query_vars['post_type'] == 'event') {
        $meta_query = array(
          array(
            'key' => '_end_ts',
            'value' => time(),
            'compare' => '>',
            'type' => 'TIME'
          )
        );
        $query->set('meta_query', $meta_query);
      }
    }
    
  • Is this the plugin you’re talking about https://wordpress.org/plugins/events-manager/ or is it another one?

  • Usually when you get a 404 error it’s because one of the query parameters is a reserved name in WP. For example ‘post_id’ and ‘name’ are reserverd. If you use these you’ll get a 404 error.

    What are the parameter names you’re trying to use?

  • Is there a custom field that you’re using to set the expiration date?

    In your loop where you’re displaying the posts you need to check this field or what you’re using to set the expiration date and compare it to the current date to decide if it should be shown or not.

  • Do you have any special characters or spaces in your custom post type slug?

  • This may be something that gets added to ACF. I know that the developer is thinking about it.

    There are some current options.
    ACF4: https://github.com/theideabureau/acf-reusable-group-field

    ACF ?: https://github.com/tybruffy/ACF-Reusable-Field-Group/ there are several forks of this one, I’m not sure which on to use.

    There is also mine that works with ACF5: https://github.com/Hube2/acf-reusable-field-group-field
    and I have this one that has a field group duplicator if you enable it that will copy field groups to multiple options pages: https://github.com/Hube2/acf-options-page-adder

    and there is this one that lets you build field groups with code that will also let you share fields in multiple groups. https://github.com/fewagency/fewbricks

  • Not sure how detailed you need be to be.

    Basically on the product archive page you query the products. Although if you created a custom post type for products and create the template file named archive-products.php then this is done for you.

    Then you loop through the products just like you’d normally do and for each product you’d do the same thing you do on the single product page, getting the fields from the related manufacturer.

    A can’t really be more specific than that because I don’t know how you’re storing the products and manufacturers or what type of field you’re using to relate them.

  • You’re creating a new post. If you’re creating a new post I’m not sure that you’d see anything in revisions. But I don’t know to be honest. I’m really not sure how well ACF front end forms work with revisions. But since it’s creating a new post then the image you provided should be correct. The fields would not contain anything before the current version of the new post.

Viewing 25 posts - 12,651 through 12,675 (of 14,467 total)