Support

Account

Home Forums Search Search Results for 'event date repeater'

Search Results for 'event date repeater'

reply

  • Figured it out!

    There’s a section of assets/js/acf_input.js that interfaces with the WordPress media library. Unfortunately it specifically targets the image field type. I ended up copying a big lump of javascript and changing the type identifier… here’s the code that I copied, notice that I just changed the ‘type’ parameter and it all worked.

    I’m sure there must be an easier way to reuse this… I assume some field authors have figured out a way to include a media picker in a more subtle way. I reckon this page would be helpful if I had time to investigate

    
    (function($, undefined){
    	
    	var Field = acf.Field.extend({
    		
    		type: 'my_new_field',
    		
    		$control: function(){
    			return this.$('.acf-image-uploader');
    		},
    		
    		$input: function(){
    			return this.$('input[type="hidden"]');
    		},
    		
    		events: {
    			'click a[data-name="add"]': 	'onClickAdd',
    			'click a[data-name="edit"]': 	'onClickEdit',
    			'click a[data-name="remove"]':	'onClickRemove',
    			'change input[type="file"]':	'onChange'
    		},
    		
    		initialize: function(){
    			
    			// add attribute to form
    			if( this.get('uploader') === 'basic' ) {
    				this.$el.closest('form').attr('enctype', 'multipart/form-data');
    			}
    		},
    		
    		validateAttachment: function( attachment ){
    			
    			// defaults
    			attachment = attachment || {};
    			
    			// WP attachment
    			if( attachment.id !== undefined ) {
    				attachment = attachment.attributes;
    			}
    			
    			// args
    			attachment = acf.parseArgs(attachment, {
    				url: '',
    				alt: '',
    				title: '',
    				caption: '',
    				description: '',
    				width: 0,
    				height: 0
    			});
    			
    			// preview size
    			var url = acf.isget(attachment, 'sizes', this.get('preview_size'), 'url');
    			if( url !== null ) {
    				attachment.url = url;
    			}
    			
    			// return
    			return attachment;
    		},
    		
    		render: function( attachment ){
    			
    			// vars
    			attachment = this.validateAttachment( attachment );
    			
    			// update image
    		 	this.$('img').attr({
    			 	src: attachment.url,
    			 	alt: attachment.alt,
    			 	title: attachment.title
    		 	});
    		 	
    			// vars
    			var val = attachment.id || '';
    						
    			// update val
    			this.val( val );
    		 	
    		 	// update class
    		 	if( val ) {
    			 	this.$control().addClass('has-value');
    		 	} else {
    			 	this.$control().removeClass('has-value');
    		 	}
    		},
    		
    		// create a new repeater row and render value
    		append: function( attachment, parent ){
    			
    			// create function to find next available field within parent
    			var getNext = function( field, parent ){
    				
    				// find existing file fields within parent
    				var fields = acf.getFields({
    					key: 	field.get('key'),
    					parent: parent.$el
    				});
    				
    				// find the first field with no value
    				for( var i = 0; i < fields.length; i++ ) {
    					if( !fields[i].val() ) {
    						return fields[i];
    					}
    				}
    								
    				// return
    				return false;
    			}
    			
    			// find existing file fields within parent
    			var field = getNext( this, parent );
    			
    			// add new row if no available field
    			if( !field ) {
    				parent.$('.acf-button:last').trigger('click');
    				field = getNext( this, parent );
    			}
    					
    			// render
    			if( field ) {
    				field.render( attachment );
    			}
    		},
    		
    		selectAttachment: function(){
    			
    			// vars
    			var parent = this.parent();
    			var multiple = (parent && parent.get('type') === 'repeater');
    			
    			// new frame
    			var frame = acf.newMediaPopup({
    				mode:			'select',
    				type:			'image',
    				title:			acf.__('Select Image'),
    				field:			this.get('key'),
    				multiple:		multiple,
    				library:		this.get('library'),
    				allowedTypes:	this.get('mime_types'),
    				select:			$.proxy(function( attachment, i ) {
    					if( i > 0 ) {
    						this.append( attachment, parent );
    					} else {
    						this.render( attachment );
    					}
    				}, this)
    			});
    		},
    		
    		editAttachment: function(){
    			
    			// vars
    			var val = this.val();
    			
    			// bail early if no val
    			if( !val ) return;
    			
    			// popup
    			var frame = acf.newMediaPopup({
    				mode:		'edit',
    				title:		acf.__('Edit Image'),
    				button:		acf.__('Update Image'),
    				attachment:	val,
    				field:		this.get('key'),
    				select:		$.proxy(function( attachment, i ) {
    					this.render( attachment );
    				}, this)
    			});
    		},
    		
    		removeAttachment: function(){
    	        this.render( false );
    		},
    		
    		onClickAdd: function( e, $el ){
    			this.selectAttachment();
    		},
    		
    		onClickEdit: function( e, $el ){
    			this.editAttachment();
    		},
    		
    		onClickRemove: function( e, $el ){
    			this.removeAttachment();
    		},
    		
    		onChange: function( e, $el ){
    			var $hiddenInput = this.$input();
    			
    			acf.getFileInputData($el, function( data ){
    				$hiddenInput.val( $.param(data) );
    			});
    		}
    	});
    	
    	acf.registerFieldType( Field );
    
    })(jQuery);
    

  • Hi
    Here is my version!

    • Plugin: Advanced Custom Fields PRO Version 5.7.13
    • Field-Structure: ‘repeater’ > ‘flexible_content’

    Big Thanks To Retani

    
    		function acfDragNDropFlexibleLayoutsBetweenRepeaters() {
    ?>
    			<script type="text/javascript">
    				
    				(function($) {
    
    					acf.add_action('ready', function($el){
    						$(".values").sortable({
    							connectWith: ".values",
    							start: function(event, ui) {
    								acf.do_action('sortstart', ui.item, ui.placeholder);
    							},
    							stop: function(event, ui) {
    								acf.do_action('sortstop', ui.item, ui.placeholder);
    								$(this).find('.mce-tinymce').each(function() {
    									tinyMCE.execCommand('mceRemoveControl', true, $(this).attr('id'));
    									tinyMCE.execCommand('mceAddControl', true, $(this).attr('id'));
    								});
    							}
    						});
    					});
    
    					acf.add_action('sortstop', function ($el) {
    
    						// check if the dropped element is within a repeater field
    							if($($el).parents('.acf-input > .acf-repeater').length) {
    
    								// get column_num from closest acf-row
    									var column_num = $($el).closest('.acf-row').attr('data-id');
    
    								// loop all (input) fields within dropped element and change / fix name
    									$($el).find('[name^="acf[field_"]').each(function() {
    										var field_name 		= 	$(this).attr('name');
    										var index_location 	= 	field_name.indexOf(']')+2;
    										var new_name 		= 	field_name.substr(0, index_location) + column_num + field_name.substr(index_location+1);
    										$(this).attr('name', new_name);
    									});
    
    								// get closest flexible-content-field and loop all layouts within this flexible-content-field
    									$($el).closest('.acf-field.acf-field-flexible-content').find('.acf-input > .acf-flexible-content > .values > .layout').each(function(index) {
    
    										// update order number
    											$(this).find('.acf-fc-layout-order:first').html(index+1);
    										
    										// loop all (input) fields within dropped element and change / fix name
    											$(this).find('[name^="acf[field_"]').each(function() {
    												var field_name 		= 	$(this).attr('name');
    												var index_location 	= 	GetSubstringIndex(field_name,']', 3)+2;
    												var new_name 		= 	field_name.substr(0, index_location) + index + field_name.substr(index_location+1);
    												$(this).attr('name', new_name);
    											});
    
    										// click already selected buttons to trigger conditional logics
    											$(this).find('.acf-button-group label.selected').trigger('click');
    									});
    							}
    					});
    
    				})(jQuery); 
    
    				function GetSubstringIndex(str, substring, n) {
    					var times = 0, index = null;
    					while (times < n && index !== -1) {
    						index = str.indexOf(substring, index+1);
    						times++;
    					}
    					return index;
    				}
    
    			</script>
    <?php
    		}
    
    		add_action('acf/input/admin_footer', 'acfDragNDropFlexibleLayoutsBetweenRepeaters');
    
  • It is not possible to order the posts by a repeater sub field, so what you want to do is not possible. Even if it were possible, the nature of WP_Query would give you additional problems.

    Let’s say for example that “Show 1” is on “date 1” and “date 2” while “Show 2” is on “date 1” and “date 3”. Using WP_Query you will only see each “Show” listed once.

    
    Date 1
      => Show 1
      => Show 2
    
    Date 2
       Nothing listed, show 1 already shown
    
    Date 3
      Nothing listed, show 2 already shown
    

    I am actually currently working on a project that has a similar problem. The client wants “Events”. Each event can happen on multiple dates. Basically the same thing that you are doing. I have no choice but to use a repeater for this. How am I solving this.

    1) I’ve made my post type hierarchical.

    2) On top level posts I have a field group with the repeater. On child posts I have a field group that contains just a start date/time and an end date/time field. This requires a custom location rule.

    3) When an event is saved I have an acf/save_post action that creates creates and deletes child posts for the event based on the dates saved in the repeater field.

    4) In the admin list of posts I am hiding the child posts so that the client cannot see them. I am also hiding the fact that they can create child posts. I have a filter on pre_get_posts for this post type in the admin and I’m using ACF “hide on screen” to hide the page attribute blocks. So, basically, the client will never see the fact that all these posts are being added and deleted.

    I will post the relevant code for the above at the end of this.

    The remaining is not done. When showing posts on the front end I will do a pre_get_posts filter that will remove parent posts from the query and order all of the child posts by their start date/end date fields. When showing links I will link to the parent post instead of the child post. I’m probably also going to need to limit the number of dates that the client is allowed to add so that updating a post does not time out.

    The following code has not been made to work for your needs, it is just provided as as example of what I’ve done so far. The only thing that I’ve done is remove the client’s name from the code. It also has not been completely tested since I’m in the process of building it.

    
    <?php 
      
      class client_name_events {
        
        private $post_type = 'events';
        
        public function __construct() {
          add_action('pre_get_posts', array($this, 'hide_children_in_admin'));
          add_filter('acf/location/rule_types', array($this, 'acf_location_rule_types'));
          add_filter('acf/location/rule_values/post_level', array($this, 'acf_location_post_level_values'));
          add_filter('acf/location/rule_match/post_level', array($this, 'acf_location_post_level_match'), 20, 3);
          add_action('acf/save_post', array($this, 'save_event'), 20);
        } // end public function __construct
        
        public function hide_children_in_admin($query) {
          if (!is_admin() || !$query->is_main_query()) {
            return;
          }
          if (!isset($query->query_vars) ||
              !isset($query->query_vars['post_type']) ||
              $query->query_vars['post_type'] != $this->post_type) {
            return;
          }
          $query->set('post_parent', 0);
        } // end public function hide_children_in_admin
        
        public function save_event($post_id) {
          if (get_post_type($post_id) != $this->post_type) {
            // not our post type
            return;
          }
          $parent = wp_get_post_parent_id($post_id);
          if ($parent) {
            // this is a child post
            // this should never happen
            // it's only here to cover all bases
            return;
          }
          
          // get all dates from repeater
          $dates = array();
          if (have_rows('dates', $post_id)) {
            while (have_rows('dates', $post_id)) {
              the_row();
              $dates[] = array(
                'start' => get_sub_field('start'),
                'end' => get_sub_field('end')
              );
            }
          }
          
          // get list of existing date posts
          $existing_dates = array();
          // get all child posts
          $args = array(
            'post_type' => 'events',
            'post_parent' => $post_id,
            'numberposts' => -1,
          );
          $children = get_children($args);
          $new = array();
          $delete = array();
          if (!empty($children)) {
            foreach ($children as $id => $event) {
              $existing_dates[$id] = array(
                'id' => $id,
                'title' => $event->post_title,
                'start' => get_field('start_date', $id),
                'end' => get_field('end_date', $id)
              );
            } // end foreach children
          } // end if !empty children
          
          // create list of dates to add
          // loop over all $dates, and all $existing_dates
          // if a date does not exist add it to the list to be added
          $add = array();
          if (count($existing_dates)) {
            foreach ($dates as $date) {
              $found = false;
              foreach ($existing_dates as $existing_date) {
                if ($date['start'] == $existing_date['start'] && $date['end'] == $existing_date['end']) {
                  $found = true;
                  break;
                }
              } // end foreach existing date
              if (!$found) {
                $add[] = $date;
              }
            } // end foreach dates
          } else {
            // no existing dates
            // add them all
            $add = $dates;
          }
          
          // create list of dates to remove
          // loop over all existing dates and all dates
          // if a date does not exist then add it to list of dates to remove
          $remove = array();
          if (count($exisiting_dates)) {
            foreach ($existing_dates as $id => $existing_date) {
              $found = false;
              foreach ($dates as $date) {
                if ($date['start'] == $existing_date['start'] && $date['end'] == $existing_date['end']) {
                  $found = true;
                  break;
                }
              }
              if (!$found) {
                $remove[] = $id;
              }
            } // end foreach existing date
          } // end if existing dates
          
          // delete posts
          if (count($remove)) {
            foreach ($remove as $id) {
              wp_delete_post($id, true);
            }
          } // end if posts to remove
          
          // add posts
          if (count($add)) {
            foreach ($add as $date) {
              $post = array(
                'post_title' => $date['start'].' to '.$date['end'],
                'post_type' => 'events',
                'post_parent' => $post_id,
                'post_status' => 'publish'
              );
              $new_id = wp_insert_post($post);
              if ($new_id) {
                update_field('field_5c6eb7f6dc628', $date['start'], $new_id);
                update_field('field_5c6eb81ddc629', $date['end'], $new_id);
              }
            } // end foreach date to add
          } // end if posts to add
        } // end public function save_event
        
        public function acf_location_rule_types($choices) {
          if (!isset($choices['Other'])) {
            $choices['Other'] = array();
          }
          if (!isset($choices['Other']['post_level'])) {
            $choices['Other']['post_level'] = 'Post Level';
          }
          return $choices;
        } // end public function acf_location_rule_types
        
        public function acf_location_post_level_values($choices) {
          $choices['top'] = 'Top Level Post';
          $choices['child'] = 'Child Post';
          return $choices;
        } // end public function acf_location_post_level_values
        
        public function acf_location_post_level_match($match, $rule, $options) {
          if ($rule['param'] == 'post_level') {
            $post_id = $options['post_id'];
            $parent = wp_get_post_parent_id($post_id);
            if ($parent) {
              $level = 'child';
            } else {
              $level = 'top';
            }
          }
          switch ($rule['operator']) {
            case '==':
              $match = ($level == $rule['value']);
              break;
            case '!=':
              $match = ($level != $rule['value']);
              break;
            default:
              // do nothing
              break;
          }
          return $match;
        } // end public function acf_location_post_level_match
        
      } // end class client_name_events
      
    ?>
    
  • i have a CPT event.
    A single event can have multiple date/time/localisation
    So i use ACF repeater for each event with line: DATEPICKER / TIMEPICKER / TEXT
    i am just wondering if there is a way to optimize my wpquery
    thanks

  • It’s repeaters nested inside of a group… Very complex:

    Array
    (
        [ID] => 10198
        [key] => field_5b21445c02e41
        [label] => Event Date
        [name] => event_date
        [prefix] => acf
        [type] => group
        [value] => Array
            (
                [event_date_type] => date
                [event_single_day] => Array
                    (
                        [0] => Array
                            (
                                [event_date] => 20181219
                                [event_time] => Array
                                    (
                                        [0] => Array
                                            (
                                                [event_start_time] => 10:00:00
                                                [event_end_time] => 10:30:00
                                            )
    
                                        [1] => Array
                                            (
                                                [event_start_time] => 10:30:00
                                                [event_end_time] => 11:00:00
                                            )
    
                                    )
    
                            )
    
                    )
    
                [event_date_range] => 
                [event_recurring_weekly] => Array
                    (
                        [event_start_date] => 
                        [event_end_date] => 
                        [event_time] => 
                        [event_recurring_days] => Array
                            (
                            )
    
                    )
    
                [event_recurring_monthly] => 
            )
    
        [menu_order] => 8
        [instructions] => 
        [required] => 1
        [id] => 
        [class] => 
        [conditional_logic] => 0
        [parent] => 15
        [wrapper] => Array
            (
                [width] => 
                [class] => 
                [id] => 
            )
    
        [_name] => event_date
        [_prepare] => 0
        [_valid] => 1
        [user_roles] => Array
            (
                [0] => all
            )
    
        [layout] => block
        [sub_fields] => Array
            (
                [0] => Array
                    (
                        [ID] => 10199
                        [key] => field_5b21449202e42
                        [label] => Type
                        [name] => event_date_type
                        [prefix] => acf
                        [type] => select
                        [value] => 
                        [menu_order] => 0
                        [instructions] => 
                        [required] => 0
                        [id] => 
                        [class] => 
                        [conditional_logic] => 0
                        [parent] => 10198
                        [wrapper] => Array
                            (
                                [width] => 25
                                [class] => 
                                [id] => 
                            )
    
                        [_name] => event_date_type
                        [_prepare] => 0
                        [_valid] => 1
                        [user_roles] => Array
                            (
                                [0] => all
                            )
    
                        [choices] => Array
                            (
                                [date] => Single Day Event
                                [range] => Date Range
                                [weekly] => Recurring Weekly
                                [monthly] => Recurring Monthly
                            )
    
                        [default_value] => Array
                            (
                                [0] => date
                            )
    
                        [allow_null] => 0
                        [multiple] => 0
                        [ui] => 0
                        [return_format] => value
                        [ajax] => 0
                        [placeholder] => 
                    )
    
                [1] => Array
                    (
                        [ID] => 10200
                        [key] => field_5b2145b902e43
                        [label] => Single Day Event
                        [name] => event_single_day
                        [prefix] => acf
                        [type] => repeater
                        [value] => 
                        [menu_order] => 1
                        [instructions] => Events that occur on a single day. You may add multiple dates and times, but each date/time is distinct and will have separate registrations, if registration is required.
                        [required] => 0
                        [id] => 
                        [class] => 
                        [conditional_logic] => Array
                            (
                                [0] => Array
                                    (
                                        [0] => Array
                                            (
                                                [field] => field_5b21449202e42
                                                [operator] => ==
                                                [value] => date
                                            )
    
                                    )
    
                            )
    
                        [parent] => 10198
                        [wrapper] => Array
                            (
                                [width] => 
                                [class] => 
                                [id] => 
                            )
    
                        [_name] => event_single_day
                        [_prepare] => 0
                        [_valid] => 1
                        [user_roles] => Array
                            (
                                [0] => all
                            )
    
                        [collapsed] => field_5b21463202e44
                        [min] => 1
                        [max] => 0
                        [layout] => block
                        [button_label] => Add Another Date
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 10201
                                        [key] => field_5b21463202e44
                                        [label] => Date
                                        [name] => event_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10200
                                        [wrapper] => Array
                                            (
                                                [width] => 20
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 10202
                                        [key] => field_5b2146c83d961
                                        [label] => Time
                                        [name] => event_time
                                        [prefix] => acf
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10200
                                        [wrapper] => Array
                                            (
                                                [width] => 79
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_time
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [collapsed] => 
                                        [min] => 1
                                        [max] => 0
                                        [layout] => table
                                        [button_label] => Add Time
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 10203
                                                        [key] => field_5b2147733d964
                                                        [label] => Start Time
                                                        [name] => event_start_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10202
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 49
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_start_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 9:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 07:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [return_format] => value
                                                        [ajax] => 0
                                                        [placeholder] => 
                                                    )
    
                                                [1] => Array
                                                    (
                                                        [ID] => 10204
                                                        [key] => field_5b2147af3d965
                                                        [label] => End Time
                                                        [name] => event_end_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 1
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10202
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 50
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_end_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [user_roles] => Array
                                                            (
                                                                [0] => all
                                                            )
    
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 9:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 08:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [return_format] => value
                                                        [ajax] => 0
                                                        [placeholder] => 
                                                    )
    
                                            )
    
                                    )
    
                            )
    
                    )
    
                [2] => Array
                    (
                        [ID] => 10214
                        [key] => field_5b2155730460b
                        [label] => Date Range
                        [name] => event_date_range
                        [prefix] => acf
                        [type] => repeater
                        [value] => 
                        [menu_order] => 2
                        [instructions] => Events that occur over a range of multiple dates with no time specified. You can add multiple date ranges.
                        [required] => 0
                        [id] => 
                        [class] => 
                        [conditional_logic] => Array
                            (
                                [0] => Array
                                    (
                                        [0] => Array
                                            (
                                                [field] => field_5b21449202e42
                                                [operator] => ==
                                                [value] => range
                                            )
    
                                    )
    
                            )
    
                        [parent] => 10198
                        [wrapper] => Array
                            (
                                [width] => 
                                [class] => 
                                [id] => 
                            )
    
                        [_name] => event_date_range
                        [_prepare] => 0
                        [_valid] => 1
                        [user_roles] => Array
                            (
                                [0] => all
                            )
    
                        [collapsed] => 
                        [min] => 1
                        [max] => 0
                        [layout] => block
                        [button_label] => Add New Date Range
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 10215
                                        [key] => field_5b2155e50460c
                                        [label] => Start Date
                                        [name] => event_start_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 
                                        [menu_order] => 0
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10214
                                        [wrapper] => Array
                                            (
                                                [width] => 20
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_start_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 10216
                                        [key] => field_5b2156130460d
                                        [label] => End Date
                                        [name] => event_end_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10214
                                        [wrapper] => Array
                                            (
                                                [width] => 20
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_end_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                            )
    
                    )
    
                [3] => Array
                    (
                        [ID] => 10221
                        [key] => field_5b215748a5c71
                        [label] => Recurring Weekly
                        [name] => event_recurring_weekly
                        [prefix] => acf
                        [type] => group
                        [value] => 
                        [menu_order] => 3
                        [instructions] => Select the days of the week the event will reoccur. Ex: Selecting Thursday will create the event EVERY Thursday. You can select multiple days of the week.
                        [required] => 0
                        [id] => 
                        [class] => 
                        [conditional_logic] => Array
                            (
                                [0] => Array
                                    (
                                        [0] => Array
                                            (
                                                [field] => field_5b21449202e42
                                                [operator] => ==
                                                [value] => weekly
                                            )
    
                                    )
    
                            )
    
                        [parent] => 10198
                        [wrapper] => Array
                            (
                                [width] => 
                                [class] => 
                                [id] => 
                            )
    
                        [_name] => event_recurring_weekly
                        [_prepare] => 0
                        [_valid] => 1
                        [user_roles] => Array
                            (
                                [0] => all
                            )
    
                        [layout] => block
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 10223
                                        [key] => field_5b21585026e20
                                        [label] => Start Date
                                        [name] => event_start_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 12/19/2018
                                        [menu_order] => 0
                                        [instructions] => Date the event will start recurring.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10221
                                        [wrapper] => Array
                                            (
                                                [width] => 20
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_start_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 10224
                                        [key] => field_5b21587526e21
                                        [label] => End Date
                                        [name] => event_end_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => Leave blank for no end date.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10221
                                        [wrapper] => Array
                                            (
                                                [width] => 20
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_end_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [2] => Array
                                    (
                                        [ID] => 10249
                                        [key] => field_5b2168d4f6092
                                        [label] => Time
                                        [name] => event_time
                                        [prefix] => acf
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 2
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10221
                                        [wrapper] => Array
                                            (
                                                [width] => 49
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_time
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [collapsed] => 
                                        [min] => 1
                                        [max] => 0
                                        [layout] => table
                                        [button_label] => Add Time
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 10250
                                                        [key] => field_5b2168fff6093
                                                        [label] => Start Time
                                                        [name] => event_start_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10249
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 33
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_start_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [user_roles] => Array
                                                            (
                                                                [0] => all
                                                            )
    
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 10:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 07:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [ajax] => 0
                                                        [return_format] => value
                                                        [placeholder] => 
                                                    )
    
                                                [1] => Array
                                                    (
                                                        [ID] => 10251
                                                        [key] => field_5b21692cf6094
                                                        [label] => End Time
                                                        [name] => event_end_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 1
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10249
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 33
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_end_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [user_roles] => Array
                                                            (
                                                                [0] => all
                                                            )
    
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 10:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 08:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [ajax] => 0
                                                        [return_format] => value
                                                        [placeholder] => 
                                                    )
    
                                            )
    
                                    )
    
                                [3] => Array
                                    (
                                        [ID] => 10225
                                        [key] => field_5b21589526e22
                                        [label] => Recurring Day(s)
                                        [name] => event_recurring_days
                                        [prefix] => acf
                                        [type] => checkbox
                                        [value] => 
                                        [menu_order] => 3
                                        [instructions] => Select the day(s) of the week the event will reoccur. If you select Thursday, the event will repeat EVERY Thursday. You can select more than one day of the week.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10221
                                        [wrapper] => Array
                                            (
                                                [width] => 
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_recurring_days
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [choices] => Array
                                            (
                                                [sunday] => Sunday
                                                [monday] => Monday
                                                [tuesday] => Tuesday
                                                [wednesday] => Wednesday
                                                [thursday] => Thursday
                                                [friday] => Friday
                                                [saturday] => Saturday
                                            )
    
                                        [allow_custom] => 0
                                        [save_custom] => 0
                                        [default_value] => Array
                                            (
                                            )
    
                                        [layout] => horizontal
                                        [toggle] => 0
                                        [return_format] => value
                                    )
    
                            )
    
                    )
    
                [4] => Array
                    (
                        [ID] => 10230
                        [key] => field_5b215ddc9226e
                        [label] => Recurring Monthly
                        [name] => event_recurring_monthly
                        [prefix] => acf
                        [type] => repeater
                        [value] => 
                        [menu_order] => 4
                        [instructions] => Select the week number and day of the week the event will reoccur.
                        [required] => 0
                        [id] => 
                        [class] => 
                        [conditional_logic] => Array
                            (
                                [0] => Array
                                    (
                                        [0] => Array
                                            (
                                                [field] => field_5b21449202e42
                                                [operator] => ==
                                                [value] => monthly
                                            )
    
                                    )
    
                            )
    
                        [parent] => 10198
                        [wrapper] => Array
                            (
                                [width] => 
                                [class] => 
                                [id] => 
                            )
    
                        [_name] => event_recurring_monthly
                        [_prepare] => 0
                        [_valid] => 1
                        [user_roles] => Array
                            (
                                [0] => all
                            )
    
                        [collapsed] => 
                        [min] => 1
                        [max] => 0
                        [layout] => block
                        [button_label] => Add Recurrance
                        [sub_fields] => Array
                            (
                                [0] => Array
                                    (
                                        [ID] => 10231
                                        [key] => field_5b215e4292273
                                        [label] => Start Date
                                        [name] => event_start_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 12/19/2018
                                        [menu_order] => 0
                                        [instructions] => Date the event will start recurring.
                                        [required] => 1
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10230
                                        [wrapper] => Array
                                            (
                                                [width] => 15
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_start_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [1] => Array
                                    (
                                        [ID] => 10232
                                        [key] => field_5b215e6292274
                                        [label] => End Date
                                        [name] => event_end_date
                                        [prefix] => acf
                                        [type] => date_picker
                                        [value] => 
                                        [menu_order] => 1
                                        [instructions] => Leave blank if there is no end date.
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10230
                                        [wrapper] => Array
                                            (
                                                [width] => 15
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_end_date
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [display_format] => m/d/Y
                                        [return_format] => Ymd
                                        [first_day] => 0
                                    )
    
                                [2] => Array
                                    (
                                        [ID] => 10233
                                        [key] => field_5b215e9e92275
                                        [label] => Recurring Week
                                        [name] => event_recurring_week
                                        [prefix] => acf
                                        [type] => select
                                        [value] => 
                                        [menu_order] => 2
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10230
                                        [wrapper] => Array
                                            (
                                                [width] => 14
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_recurring_week
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [choices] => Array
                                            (
                                                [first] => First
                                                [second] => Second
                                                [third] => Third
                                                [fourth] => Fourth
                                            )
    
                                        [default_value] => Array
                                            (
                                            )
    
                                        [allow_null] => 0
                                        [multiple] => 0
                                        [ui] => 0
                                        [ajax] => 0
                                        [return_format] => value
                                        [placeholder] => 
                                    )
    
                                [3] => Array
                                    (
                                        [ID] => 10234
                                        [key] => field_5b215eed92276
                                        [label] => Day
                                        [name] => event_recurring_day
                                        [prefix] => acf
                                        [type] => select
                                        [value] => 
                                        [menu_order] => 3
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10230
                                        [wrapper] => Array
                                            (
                                                [width] => 14
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_recurring_day
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [choices] => Array
                                            (
                                                [sunday] => Sunday
                                                [monday] => Monday
                                                [tuesday] => Tuesday
                                                [wednesday] => Wednesday
                                                [thursday] => Thursday
                                                [friday] => Friday
                                                [saturday] => Saturday
                                            )
    
                                        [default_value] => Array
                                            (
                                                [0] => friday
                                            )
    
                                        [allow_null] => 0
                                        [multiple] => 0
                                        [ui] => 0
                                        [ajax] => 0
                                        [return_format] => value
                                        [placeholder] => 
                                    )
    
                                [4] => Array
                                    (
                                        [ID] => 10257
                                        [key] => field_5b216a933dfdc
                                        [label] => Time
                                        [name] => event_time
                                        [prefix] => acf
                                        [type] => repeater
                                        [value] => 
                                        [menu_order] => 4
                                        [instructions] => 
                                        [required] => 0
                                        [id] => 
                                        [class] => 
                                        [conditional_logic] => 0
                                        [parent] => 10230
                                        [wrapper] => Array
                                            (
                                                [width] => 40
                                                [class] => 
                                                [id] => 
                                            )
    
                                        [_name] => event_time
                                        [_prepare] => 0
                                        [_valid] => 1
                                        [user_roles] => Array
                                            (
                                                [0] => all
                                            )
    
                                        [collapsed] => 
                                        [min] => 1
                                        [max] => 0
                                        [layout] => table
                                        [button_label] => Add Time
                                        [sub_fields] => Array
                                            (
                                                [0] => Array
                                                    (
                                                        [ID] => 10258
                                                        [key] => field_5b216aa53dfdd
                                                        [label] => Start Time
                                                        [name] => event_start_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 0
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10257
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 49
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_start_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [user_roles] => Array
                                                            (
                                                                [0] => all
                                                            )
    
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 10:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 07:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [ajax] => 0
                                                        [return_format] => value
                                                        [placeholder] => 
                                                    )
    
                                                [1] => Array
                                                    (
                                                        [ID] => 10259
                                                        [key] => field_5b216ad03dfde
                                                        [label] => End Time
                                                        [name] => event_end_time
                                                        [prefix] => acf
                                                        [type] => select
                                                        [value] => 
                                                        [menu_order] => 1
                                                        [instructions] => 
                                                        [required] => 0
                                                        [id] => 
                                                        [class] => 
                                                        [conditional_logic] => 0
                                                        [parent] => 10257
                                                        [wrapper] => Array
                                                            (
                                                                [width] => 49
                                                                [class] => 
                                                                [id] => 
                                                            )
    
                                                        [_name] => event_end_time
                                                        [_prepare] => 0
                                                        [_valid] => 1
                                                        [user_roles] => Array
                                                            (
                                                                [0] => all
                                                            )
    
                                                        [choices] => Array
                                                            (
                                                                [06:00:00] => 6:00am
                                                                [06:15:00] => 6:15am
                                                                [06:30:00] => 6:30am
                                                                [06:45:00] => 6:45am
                                                                [07:00:00] => 7:00am
                                                                [07:15:00] => 7:15am
                                                                [07:30:00] => 7:30am
                                                                [07:45:00] => 7:45am
                                                                [08:00:00] => 8:00am
                                                                [08:15:00] => 8:15am
                                                                [08:30:00] => 8:30am
                                                                [08:45:00] => 8:45am
                                                                [09:00:00] => 9:00am
                                                                [09:15:00] => 9:15am
                                                                [09:30:00] => 9:30am
                                                                [09:45:00] => 9:45am
                                                                [10:00:00] => 10:00am
                                                                [10:15:00] => 10:15am
                                                                [10:30:00] => 10:30am
                                                                [10:45:00] => 10:45am
                                                                [11:00:00] => 11:00am
                                                                [11:15:00] => 11:15am
                                                                [11:30:00] => 11:30am
                                                                [11:45:00] => 11:45am
                                                                [12:00:00] => 12:00pm
                                                                [12:15:00] => 12:15pm
                                                                [12:30:00] => 12:30pm
                                                                [12:45:00] => 12:45pm
                                                                [13:00:00] => 1:00pm
                                                                [13:15:00] => 1:15pm
                                                                [13:30:00] => 1:30pm
                                                                [13:45:00] => 1:45pm
                                                                [14:00:00] => 2:00pm
                                                                [14:15:00] => 2:15pm
                                                                [14:30:00] => 2:30pm
                                                                [14:45:00] => 2:45pm
                                                                [15:00:00] => 3:00pm
                                                                [15:15:00] => 3:15pm
                                                                [15:30:00] => 3:30pm
                                                                [15:45:00] => 3:45pm
                                                                [16:00:00] => 4:00pm
                                                                [16:15:00] => 4:15pm
                                                                [16:30:00] => 4:30pm
                                                                [16:45:00] => 4:45pm
                                                                [17:00:00] => 5:00pm
                                                                [17:15:00] => 5:15pm
                                                                [17:30:00] => 5:30pm
                                                                [17:45:00] => 5:45pm
                                                                [18:00:00] => 6:00pm
                                                                [18:15:00] => 6:15pm
                                                                [18:30:00] => 6:30pm
                                                                [18:45:00] => 6:45pm
                                                                [19:00:00] => 7:00pm
                                                                [19:15:00] => 7:15pm
                                                                [19:30:00] => 7:30pm
                                                                [19:45:00] => 7:45pm
                                                                [20:00:00] => 8:00pm
                                                                [20:15:00] => 8:15pm
                                                                [20:30:00] => 8:30pm
                                                                [20:45:00] => 8:45pm
                                                                [21:00:00] => 10:00pm
                                                                [21:15:00] => 9:15pm
                                                                [21:30:00] => 9:30pm
                                                                [21:45:00] => 9:45pm
                                                                [22:00:00] => 10:00pm
                                                                [22:15:00] => 10:15pm
                                                                [22:30:00] => 10:30pm
                                                                [22:45:00] => 10:45pm
                                                                [23:00:00] => 11:00pm
                                                                [23:15:00] => 11:15pm
                                                                [23:30:00] => 11:30pm
                                                                [23:45:00] => 11:45pm
                                                                [00:00:00] => 12:00am
                                                            )
    
                                                        [default_value] => Array
                                                            (
                                                                [0] => 08:00:00
                                                            )
    
                                                        [allow_null] => 0
                                                        [multiple] => 0
                                                        [ui] => 0
                                                        [ajax] => 0
                                                        [return_format] => value
                                                        [placeholder] => 
                                                    )
    
                                            )
    
                                    )
    
                            )
    
                    )
    
            )
    
    )
  • Yes, getting a value and then using that value to update another post with the same data will fail, I don’t even need to test it. The reason is that when you use get_field(), even if you use the field key, the nested sub fields in it will be by field name and not field key, so it fails.

    In your code example:

    
    $date_meta = array();
    $date_meta['field_5b21449202e42'] = 'date'; //event_date_type
    $date_meta['field_5b2145b902e43'][0] = array( //event_single_day
    
    // this is the field your are updating in the
    // update field call below
            'field_5b21463202e44' => $date, //event_date 
    
            'field_5b2146c83d961' => array( //event_time
                0 => array(
                    'field_5b2147733d964' => $time, //event_start_time
                    'field_5b2147af3d965' => $time, //event_end_time
                    )
                )
            );
    update_field( 'field_5b21463202e44', $date_meta, $id ); //event_date
    

    field_5b21463202e44 looks like a nested repeater, see my notes above. Is this correct?

  • Hi,

    I’m having an issue with displaying multiple google maps that are not in an accordion.

    I created a repeater for different locations, for each row I have the name of the location and the google map field. I tried to output that in my template using the code provided by ACF, but the maps appear with no pin/marker, and are not in the right spot on the map.

    If I have only one row in my repeater, it works fine. So I’m assuming that it’s a problem between the js and my html elements.

    Each map div has the class .acf-map, but I see in the js that it uses .each to make sure it works for multiple maps.

    Is there something wrong with my code? (note that I don’t want multiple markers in one map, but multiple maps with each one marker).

    <?php if(have_rows('contact_locations_repeater')): ?>
    				<?php while(have_rows('contact_locations_repeater')): the_row(); ?>
    					<div class="location">
    						<div class="map">
    							<!-- GOOGLE MAP-->
    							<?php 
    							$location = get_sub_field('google_map');
    							if( !empty($location) ):
    							?>
    							<div class="acf-map">
    								<div class="marker" data-lat="<?php echo $location['lat']; ?>" data-lng="<?php echo $location['lng']; ?>"></div>
    							</div>
    
    							<?php endif; ?>
    							<!-- END GOOGLE MAP-->  
    						</div>
    						
    							<script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDsVBtPm96bvZOTLPy6yBxGBxHE9TU8mtw"></script>
    							<script type="text/javascript">
    							(function($) {
    
    							/*
    							*  new_map
    							*
    							*  This function will render a Google Map onto the selected jQuery element
    							*
    							*  @type	function
    							*  @date	8/11/2013
    							*  @since	4.3.0
    							*
    							*  @param	$el (jQuery element)
    							*  @return	n/a
    							*/
    
    							function new_map( $el ) {
    
    								// var
    								var $markers = $el.find('.marker');
    
    								// vars
    								var args = {
    									zoom		: 18,
    									center		: new google.maps.LatLng(0, 0),
    									mapTypeId	: google.maps.MapTypeId.ROADMAP
    								};
    
    								// create map	        	
    								var map = new google.maps.Map( $el[0], args);
    
    								// add a markers reference
    								map.markers = [];
    
    								// add markers
    								$markers.each(function(){
    
    									add_marker( $(this), map );
    
    								});
    
    								// center map
    								center_map( map );
    
    								// return
    								return map;
    
    							}
    
    							/*
    							*  add_marker
    							*
    							*  This function will add a marker to the selected Google Map
    							*
    							*  @type	function
    							*  @date	8/11/2013
    							*  @since	4.3.0
    							*
    							*  @param	$marker (jQuery element)
    							*  @param	map (Google Map object)
    							*  @return	n/a
    							*/
    
    							function add_marker( $marker, map ) {
    
    								// var
    								var latlng = new google.maps.LatLng( $marker.attr('data-lat'), $marker.attr('data-lng') );
    
    								// create marker
    								var marker = new google.maps.Marker({
    									position	: latlng,
    									map			: map,
    									title:    'DSRU',
    									icon:     '<?php the_field('map_pin');?>' 
    								});
    
    								// add to array
    								map.markers.push( marker );
    
    								// if marker contains HTML, add it to an infoWindow
    								if( $marker.html() )
    								{
    									// create info window
    									var infowindow = new google.maps.InfoWindow({
    										content		: $marker.html()
    									});
    
    									// show info window when marker is clicked
    									google.maps.event.addListener(marker, 'click', function() {
    
    										infowindow.open( map, marker );
    
    									});
    								}
    
    							} 
    
    							/*
    							*  center_map
    							*
    							*  This function will center the map, showing all markers attached to this map
    							*
    							*  @type	function
    							*  @date	8/11/2013
    							*  @since	4.3.0
    							*
    							*  @param	map (Google Map object)
    							*  @return	n/a
    							*/
    
    							function center_map( map ) {
    
    								// vars
    								var bounds = new google.maps.LatLngBounds();
    
    								// loop through all markers and create bounds
    								$.each( map.markers, function( i, marker ){
    
    									var latlng = new google.maps.LatLng( marker.position.lat(), marker.position.lng() );
    
    									bounds.extend( latlng );
    
    								});
    
    								// only 1 marker?
    								if( map.markers.length == 1 )
    								{
    									// set center of map
    									map.setCenter( bounds.getCenter() );
    									map.setZoom( 16 );
    								}
    								else
    								{
    									// fit to bounds
    									map.fitBounds( bounds );
    								}
    
    							}
    
    							/*
    							*  document ready
    							*
    							*  This function will render each map when the document is ready (page has loaded)
    							*
    							*  @type	function
    							*  @date	8/11/2013
    							*  @since	5.0.0
    							*
    							*  @param	n/a
    							*  @return	n/a
    							*/
    							// global var
    							var map = null;
    
    							$(document).ready(function(){
    
    								$('.acf-map').each(function(){
    
    									// create map
    									map = new_map( $(this) );
    
    								});
    
    							});
    
    							})(jQuery);
    							</script>		
    						<div class="text_block">
    							<h3><?php the_sub_field('contact_location_name');?></h3>
    							<p><?php the_sub_field('contact_location_address');?></p>
    						</div>
    					</div>			   
    				<?php endwhile;?>
    			<?php endif;?>
  • Hey @hube2

    Thanks for your help here. I am just touching back on this now. I put my repeater and date fields in the two specified areas, along with the_title in the loop area so my code looks like this:

    <?php // get relationship field without formatting
    // returns an array of post ID values
    $posts_ids = get_field('seminars', false, false);
    // do your own query to order the posts
    $args = array(
      'post_type' => 'any',
      'posts_per_page' => -1,
      'post__in' => $post_ids,
      'meta_query' => array(
        'date_clause' => array(
          'key' => 'event_time',
          'value' => 'EXISTS'
        ),
      ),
      'orderby' => array('date_clause' => 'ASC');
    );
    $custom_query = new WP_Query($args);
    if ($custom_query=>have_posts()) {
      while ($custom_query=>have_posts()) {
        $custom_query=>the_post();
        the_title();
      }
    }
    wp_reset_postdata();
    ?>

    However I get a php error at this line:
    'orderby' => array('date_clause' => 'ASC');

    [08-Oct-2018 14:29:58 UTC] PHP Parse error: syntax error, unexpected ‘;’, expecting ‘)’ in /home/clientname/public_html/wp-content/themes/mytheme/template-parts/content-attorney.php on line 182

    I’ve been playing find the syntax error with no luck. Anything glaringly obvious to you?

  • If you are sure that you’ll only ever use the first row of the repeater then the meta key for your first date sub field will always be event_dates_0_event_dates_date

    As a side note, because of the way ACF names field you don’t need to name your sub field event_dates_date and you can just shorten that to date and this would result in the first row always having the meta key of event_dates_0_date

  • Nevermind just figured it out, I nested the forloops

    Heres my code if it helps someone else, just trying to stop it from returning values that dont relate to the current post:

    function acf_event_cost_options( $form ){
    
        foreach ($form['fields'] as &$field) {
    
            if(strpos($field->cssClass, 'acf_event_cost_options') === false)
                continue;
            //This only auto-populates a field which has the class dynamicfield. If it doesn't then, continue ! Don't forget to add a class to the field you want to dynamically populate in your form.
    
            global $post;
            $id = $post->ID; 	//  Important - this is what tells the form to only use values from the individual post, not all posts
    
            global $wpdb;
            $rows_name = $wpdb->get_results($wpdb->prepare(
                "
                SELECT *
                FROM wp_postmeta
                WHERE post_id = %d AND meta_key LIKE %s 
                ",
                $id,
                'event_cost_structure_%_option_name'  //enter the actual name of your repeater field and sub-field names, the % is a variable that represents the row number
            ));
    
            $rows_price = $wpdb->get_results($wpdb->prepare(
                "
                SELECT *
                FROM wp_postmeta
                WHERE post_id = %d AND meta_key LIKE %s 
                ",
                $id,
                'event_cost_structure_%_option_price'  //enter the actual name of your repeater field and sub-field names, the % is a variable that represents the row number
    
            ));
    
            $choices = array(array('text' => 'Please Choose an Option', 'value' => ' ', 'price' => ' '));
            //Default choice for dynamic select field. Value is blank, so if it's required it won't validate, change the text to what you want it to be, e.g. 'Please Choose:'
    
            if( $rows_name || $rows_price ) {
                foreach ($rows_name as $row_name) {
                    foreach ($rows_price as $row_price) {
                        //If there are results, for each result, find the 'repeater row number'
                        preg_match('_([0-9]+)_', $row_name->meta_key, $matches);
    
                        $meta_key = 'event_cost_structure_' . $matches[0] . '_option_name';
                        $value = get_post_meta($post->ID, $meta_key, true);
                        //Get the subfield value from the row.
    
                        //If there are results, for each result, find the 'repeater row number'
                        preg_match('_([0-9]+)_', $row_price->meta_key, $matches);
    
                        $meta_key_price = 'event_cost_structure_' . $matches[0] . '_option_price';
                        $value_price = get_post_meta($post->ID, $meta_key_price, true);
                        //Get the subfield value from the row.
    
                        $choices[] = array('text' => $value . ' $' . $value_price . '.00', 'value' => $value, 'price' => $value_price);
                        //Create an option array for each subfield value.
                    }
                }
            }
    
            $field->choices = $choices;
            //Once we've looped through all of the subfields values and created all of our options, we assign the $choices array (which has all of our new options) to the $field choices property.
    
        }
    
        return $form;
        //Display the new dynamically populated form.
    }
  • For your first issue, groupings are treated similar to repeater fields but there is a single row of data in that value.

    Visually, it appears as a repeater within a repeater.

    <?php
    
    // Check for grouping.
    if ( have_rows( 'price_information' ) ) :
    	while ( have_rows( 'price_information' ) ) : the_row();
    
    		// Check for repeater.
    		if ( have_rows( 'event_cost_structure' ) ) :
    
    			// Loop through the rows of data.
    			while ( have_rows( 'event_cost_structure' ) ) : the_row(); ?>
    
    				<p><?php the_sub_field( 'option_name' ); ?> : <?php the_sub_field( 'option_price' ); ?></p>
    
    			<?php
    			endwhile;
    		endif;
    	endwhile;
    else :
    	// No rows found.
    endif; ?>

    For the second issue, it seems to format the date correctly on my end…What are your organizations and settings in regards to the display/return format for the Date Picker?

  • I’m with @nathanaelphilip on this one. Rolling your own chat system is probably not the way I’d go. There are already plugins for integrating chat into WP, like this one https://wordpress.org/plugins/wp-live-chat-support/

    As far as cons for using ACF repeater fields, or ACF at all…

    ACF is a great plugin but it has it’s limitations. Performance of ACF on a high traffic site where you’d need to store thousands of messages in the meta table would likely (eventually) crash the entire thing. You have to remember that ACF uses WP core built in meta table and meta functions for data storage and retrieval and it is the core functionality of WP meta that actually creates the limitations of ACF. ACF is tool for creating admin pages that are easy to use.

    Think about what you would need to do in WP if you didn’t have ACF just using update_post_meta() and get_post_meta(). Not to mention that every chat string would need to have it’s own “Post” with related information about who is allowed to access it. What would hundreds of thousands of posts do to WP?

    There is also the problem you mentioned of two or more people trying to update the same information at exactly the same time. I’d assume that this would be rare, but if you tried to perform to updates to the database at the same time, to be honest, I don’t know what the results would be. You could either loose a message or end up with DB errors that crash one side of the conversation.

    This site does not even use ACF for this forum. It uses BBPress with some modifications done using ACF.

  • You probably saw this coming, but the answer to all your questions is “It depends”.

    I have been using ACF for so long that I do not remember a site I’ve built without it. Every site I build for a client is custom based on their needs.

    1. Is there anything like too many ACF fields? Or you always recommend to use ACF.

    The answer to this one is Yes. But mostly this has to do with repeaters and flexible content and saving the post. The number of ACF fields will rarely impact the performance of the front end of the site.

    When you have a lot of repeaters and flex fields, and depending on what types of fields you are using, the number of fields can impact the performance of the admin in 2 ways.

    The first is that the loading of the post editor could be slow when there are a lot of fields that depend on JavaScript, like any of the jQuery fields, this also includes WYSIWYG fields that depend on tinyMCE. When building complex field groups it is important to take advantage of the “Delayed Initialization” provided by some of the ACF fields.

    The second way that it effect the performance of the admin is when saving a post. There is a point where the save process can time out.

    I’ll give you an example of this. I once built a site for a client that had a repeater. Each row of the repeater had 7 WYSIWYG fields. The content of the page required specific formatting for layout out these content fields in a very structured way to meed the client’s requirements. All went well until the client decided to add 30… let’s call them “Panels” to one page of the site. This meant that ACF needed to save 210 WYSIWYG fields and related fields for determining other options. What happened was that the save took longer that 30 seconds, which meant the the browser timed out and it appeared that it crashed the site. (In reality, it was just the browser timing out. The update went merrily on it’s way in the background and completed successfully. When this happens you can wait a minute or 3, use the browser back button and then refresh the editor and all of the changes would appear.) It was because of this that I built this https://github.com/Hube2/acf-prevent-timeouts.

    When building something for a client using ACF it is important to think about how the client can abuse your masterpiece. I did not know that this problem existed when I built this site, but knowing it now I would not build another one the same way. I would likely use a post type using a parent page/post and child pages/posts in order to break things up and therefore avoiding the issue.

    2. When certain layout becomes too complex with tiny fields for everything, do you still use ACF or you look for page builder options in such scenarios?

    I have never used a page builder. I’ve found that they are too generic. They also rarely meet the specific requirements of my clients. Like I said, I build custom sites to exactly match the client’s needs. ACF allows me to do this without trying to shoehorn them into something that may not be exactly what they wanted. I also find that most page builders are bloated and also give the client too many options that allow them to break things easily. When using ACF I can give them only the options that they need. It makes my life easier because it’s harder for them to break things. And it makes their life easier because there is less for them to learn in order to manage their own site. My goal, when building a site is to turn it over to the client and for them to be able to do everything they need. The last thing I ever want to do is manage the content of a client’s site or need to make changes because they cannot understand how to do it themselves.

    3. Finally, lets say you are working on a blog. And at some point you want some custom structures in the middle of article, maybe a table or some other layout. How do you approach it? Do you create ACF templates and split up content area with repeater field so you can use these custom structures in the middle of articles? Or again do you take some other approach?

    The answer to this one is the biggest “It Depends” answer.

    For a blog… meaning “Blog Posts”. for this they usually get just the standard WP editor. Blogs are free form and all content and formatting inside of “The Content” area is up to the client. I may provide other options on the blog, for example a way to allow them to specify a banner image for the page, or some special feature. However, I will never build a way that requires special formatting and layout within this area.

    For the rest of the site. For example, page layouts and custom post types. These are almost always formatted specifically. Meaning that every page must look the same as every other page with set features. These features may be optional on each page, but when they appear they will always be shown in the same place and always appear the same when shown. These pages, templates and post types will have fields for everything that the client should be able to control. Outside of the blog, almost all of my clients require that the structure of specific pages be the same and meets there companies style guide. I may need to build them many specific templates for different page layouts. On occasion I also have included a generic page where the content is just a basic content field where they can control the layout, but this is rare and the client that wants this is usually familiar with WP and the use of things like shortcodes and editing HTML directly.

    In the case you mentioned about a “blog” with custom structures in the middle of the content. If this was a requirement given to me by the client I would likely give them 2 content editors, one for the beginning of the blog and one for the end and the other fields in the middle and it would be up to them do decide where this special feature would be inserted. The other option would be to build a custom shortcode so that they can insert the special features into their page. But like I keep saying, that would depend on the client’s specific needs.

  • As long as $team_code is a post ID (Integer) that represents the post you want to set the field and $post_id is the post ID of the post where you want to set this value and you use the field key for the field and this field is not some type of a sub field, like a field in a group field, or a clone field, or a repeater or flex field then

    
    update_field($field_key, $team_code, $post_id);
    

    should be updating the field.

    If the field is being set in the DB and your not seeing it on the front end, do you see this change in the admin?

    Do you have any caching plugins installed that would prevent this change being reflected on the front end?

  • I have this code example for a project if it helps (it’s not WP_Query but get_posts, seance is my custom post type, seances a repeater field and film is a relationship field) :

    <?php 
                            $today = date("Ymd");
                            $date = strtotime($today);
                            $seances = get_posts(array(
                                'suppress_filters' => FALSE,
                                'post_type' => 'seance',
                                'meta_key'  => 'date',
                                'orderby'   => 'meta_value_num',
                                'order'=>'ASC',
                                'meta_query' => array(
                                    'relation'      => 'AND',
                                    array(
                                        'key' => 'seances_%_film', // name of custom field
                                        'value' => '"' . get_the_ID() . '"', // matches exaclty "123", not just 123. This prevents a match for "1234"
                                        'compare' => 'LIKE'
                                        ),
                                     array(
                                        'key'       => 'date',
                                        'compare'   => '>=',
                                        'value'     => $today,
                                    )
                                    )
                                ));
                        ?>

    And in functions.php

    function my_posts_where( $where ) {
        global $wpdb;
        $where = str_replace(
                  "meta_key = 'seances_", 
                  "meta_key LIKE 'seances_",
                  $wpdb->remove_placeholder_escape($where)
        );
        return $where;
    }
     
    add_filter('posts_where', 'my_posts_where');
  • Within the events repeater, all of your field names except the one that is working use dashes in their field key names vs. underscores. Underscores are the default structure so I would check to make sure your variables are calling correct field names and it shouldn’t be event_date, event_name, etc. vs. event-date, event-name like you have.

  • You could go back to using the Date Picker and use JavaScript and JQuery to disable the fields.

    Here’s some code that I used in a recent project to do that, which demonstrates how to Disable various field types (Date Picker, Button Group/Radio Buttons, Select, Textarea, Repeater, WP Title)…

    
    /* START: Prevent editing of Support Ticket fields for specific roles */
    function cc_prevent_editing_support_ticket_fields_after_publish() {
      global $pagenow;
      if ( !is_admin() ) { return; } // only in wp-admin
      if ( $pagenow=='post-new.php' ) { return; } // not for 'new posts'
    
     // only for specific post type(s)
      $post_types = array('supporttickets');
      if ( !in_array( get_post_type(), $post_types ) ) { return; }
    
     // only for specific role(s)
      $user = wp_get_current_user();
      $user_role_id = $user->roles[0];
      $exempt_roles = array('administrator', 'owner', 'controller');
      if ( !in_array( $user_role_id, $exempt_roles ) ) {
    ?>
    <script type='text/javascript'>
      ( function ( $ ) {
        $( document ).ready( function () {
          $('#idOfDatePicker .acf-date-picker .hasDatepicker').prop('disabled','disabled'); // disable 'Date Picker' field
          $('#acf-field_59d9867971a81').prop('disabled','disabled'); // disable 'Select' field
          $('input[type="radio"][name="acf[field_59d94c7897682]"]').prop('disabled','disabled'); // disable 'Button Group' or 'Radio Buttons'
          $('#title').prop('disabled','disabled'); // disable WordPress Post Title
          $('#acf-field_59d968a0dc7a7').prop('disabled', true); // disable 'Textarea' field
          $('.acf-field-59daa7de17e69 .acf-actions').hover(function() {
            $(this).css('display','none');
          }); // removes delete button from 'Repeater Rows' on 'hover'
          $('.acf-field-59daa7de17e69 .acf-actions').css('display','none'); // removes delete button from 'Repeater Rows'
          $('.acf-field-59daa7ae17e68 a[data-event="add-row"]').remove(); // remove 'Add Row' button for 'Repeater' field
          $('.acf-field-59daa7ae17e68 a[data-event="remove-row"]').remove(); // remove 'Remove Row' button for 'Repeater' field
        });
      }( jQuery ) );
    </script>
    <?php
      }
    }
    add_action( 'edit_form_advanced', 'cc_prevent_editing_support_ticket_fields_after_publish' );
    /* END: Prevent editing of Support Ticket fields for specific roles */
    

    Hopefully that helps… you can target any HTML element in various ways and disable them. You can even add a specific ID or Class to your Date Picker fields in the Edit Fields screen for the field (next to ‘Wrapper Attributes’), and then target it that way (like I did at the top of JavaScript).

    ‘Disable’ is essentially the same as ‘Read Only’ for most purposes. However, when creating a *new* post, and you give a field a default value AND disable it, the value won’t Submit. So, if you are doing that… you will need to add more JavaScript that re-enables the form field upon click of the Submit button.

    At any rate, the above should get you going if you want to disable fields other than just the Basic fields.

  • Hi @mrspabs

    Below is some code cleaned up a bit. I am assuming that 2006 is your Post ID? You don’t need to pass that to sub fields of your repeater, but it doesn’t hurt.

    I just added an extra bit to the ‘while’ statement making sure to only loop 3 times. I created the iteration variable just above the while statement with a value of 0. I then increment that value at the end of the while. Hope this helps! Please mark this thread as resolved if so, otherwise please reply with more questions.

    <?php
    date_default_timezone_set( 'America/Los_Angeles' );
    $today = date( 'Ymd' );
    if ( have_rows( 'events', 37 ) ) {
    ?>
    <ul>
    <?php
      $i = 0;
      while ( have_rows( 'events', 37 ) && $i<4 ) {
        the_row();
        $expire = get_sub_field( 'expire_on' );
        if ( $expire > $today ) {
    ?>
    <li class="eventrow event<?php echo get_row_index(); ?>">
      <h3>
        <a target="_blank" href="<?php the_sub_field( 'events_link' ); ?>">
          <?php the_sub_field( 'events_title' ); ?>
        </a>
      </h3>
      <p>
        <?php the_sub_field( 'events_date' ); ?><br />
        <em><?php the_sub_field( 'events_location' ); ?></em>
      </p>
    </li>
    <?php
        }
        $i++;
      }
    ?>
    </ul>
    <?php
    }
    ?>

    p.s. Thanks for teaching me about the get_row_index() function!

  • Solved!

    Since it’s in an repeater, it needed to be;

    $date = get_sub_field('event_date', false, false);

    instead of “get_field” it needed to be “get_sub_field”

  • I know this is an old post but it is exactly what I need to do. I am using a date and time picker field for both start and end of an event. I need to make it so that the end date and time can only be after the start date and time. I have googled for hours trying to find a solution but this one is as close as i have gotten. What i could really use is an elaboration on your suggestion.

    I am currently using a repeater field with start and end fields. What else would you need to assist me in this, or can you recommend a place for me to look. Thank you so much for helping me out.

  • This functionality has recently been added to the checkbox field, it was originally only part of the radio field. I imagine that eventually it will find it’s way into the select field as well.

    In the mean time, a work-a-round

    Create your select field that has a choice of “Other”
    Create a text field with conditional logic to show if “Other” is selected for the choice.

    That’s the easy bit.

    For the saving of the new value as a choice I would recommend looking at the code that does this for the checkbox field

    
    // FROM advanced-custom-fields-pro/fields/checkbox.php LINE 368 
    
    // save_other_choice
    if( $field['save_custom'] ) {
      
      // get raw $field (may have been changed via repeater field)
      // if field is local, it won't have an ID
      $selector = $field['ID'] ? $field['ID'] : $field['key'];
      $field = acf_get_field( $selector, true );
      
      
      // bail early if no ID (JSON only)
      if( !$field['ID'] ) return $value;
      
      
      // loop
      foreach( $value as $v ) {
        
        // ignore if already eixsts
        if( isset($field['choices'][ $v ]) ) continue;
        
        
        // unslash (fixes serialize single quote issue)
        $v = wp_unslash($v);
        
        
        // append
        $field['choices'][ $v ] = $v;
        
      }
      
      
      // save
      acf_update_field( $field );
      
    }    
    

    basically, you need to get the current field, update the choices with your addition and then call acf_update_field().

  • Hi @britta , please, can you post your complete solution to @b1naryb0y original question ? I can’t understand what you made to get working.

    Me, I had to take an alternative approach.

    The following code will never work for repeater fields:

    $args = array (
    		    'post_type' => 'event',
    		    'meta_query' => array(
    			    'relation'		=> 'AND',
    				array(
    			        'key'		=> 'event_dates_%_start_date',
    			        'compare'	=> '<=',
    			        'value'		=> '20150524',
    			    ),
    			     array(
    			        'key'		=> 'event_dates_%_end_date',
    			        'compare'	=> '>=',
    			        'value'		=> '20150524',
    			    )
    		    ),
    		);

    As suggested by @mediawerk , event_dates_0_start_date AND event_dates_1_end_date accomplish the start before testdate and end after testdate.

    So I replaced it with:

    array(  
                  'key' => 'opening_dates',
                  'value' => 20150524,
                  'compare' => 'LIKE'
                 ),
    			

    The 'opening_dates' postmeta field contains all the single dates resulting from the repeating “start_date"/"end_date" couple and it was created with this code of mine placed in functions.php using the "acf/save_post" hook:

    
    	function create_opening_dates_array_when_saving_post_with_repeating_start_end_dates($post_id) {
    	
    	
    		// bail early the post type to apply
    		// src: https://support.advancedcustomfields.com/forums/topic/acfsave_post-action/
    		$post_type = get_post_type($post_id);
    			if ($post_type != 'event' ) {
    				return;
    			}
    			
    			
    			// not used here
    			$fields = $_POST['acf']; 
    			
    			// $intervals will contain the interval couples: ['single_interval']=> array("20170301", "20170320")
    			$intervals = array();
    			
    			
    			// 
    			// loop repeater fields
    			if( have_rows('event_dates') ):
    			
    			 	// loop through the rows of data
    			    while ( have_rows('event_dates') ) : the_row();
    			
    			       // for each row, get the "from" "to" couple and save it in the "single_interval" key (array) in the intervals array
    			       $from =  get_sub_field('start_date', false, false);
    			       $to =  get_sub_field('end_date', false, false);
    			       $intervals[]['single_interval'] = array($from, $to);
    
    			
    			    endwhile;
    			
    			else :
    			
    			    // no rows found
    			
    			endif;
    			 
    		// here will be saved the opening date vales	
    		$final_array = array();
    
    		 // loop the array containing the couples of intervals
    		 foreach($intervals as $single_interval) {
    			 
    			 // $intervals = array("20170301", "20170320")
    			 foreach($single_interval as $intervals) {
    			 	
    			 	// fill in missing in-between dates...
    				$arrays_of_single_dates = getDatesFromRange($intervals[0], $intervals[1]);
    				
    				// loop the resulting array and save each single value in the final array...
    				foreach($arrays_of_single_dates as $single) {
    					$final_array[] = intval($single); // from string to integer
    				}
    			}
    		
    		};
    	  // var_dump($final_array);
    	  
    	  
    	  // create or update a meta_key field called "opening_dates" and set as meta_value the $final_array containing all the opening dates
    	  update_post_meta( $post_id, 'opening_dates', $final_array);
    
    	 // var_dump($final_array);	  
    	};
    
    	
    	add_action('acf/save_post', 'create_opening_dates_array_when_saving_post_with_repeating_start_end_dates', 1);
    

    I’ve got the getDatesFromRange function from here.

    I wonder if @Elliot knows a simpler and better performing solution anyway…

  • You are right, there isn’t any way to do this using WP_Query. Doing this on the event date archive is going to be extremely complicated. Well, doing it anywhere is going to be complicated because event category is not really related to the event date except through the event.

    Doing this with just the basic function that WP gives us you would need to… and I’m not sure about this

    1) Get all the even categories
    2) Get all the events in each category
    3) Somehow sort them by the event date and there isn’t any way to sort posts based on a field in another post

    What you need to be able to do is one WP_query on the events. The best way to accomplish this is to store all of the information you need to query as part of the event.

    I’ve posted several replies here about making repeaters easier to search and this is the same basic principle. You take information that you want and copy it to where it will help you the most.

    
    add_action('acf/save_post', 'make_events_filterable');
    function make_events_filterable($post_id) {
      if (get_post_type($post_id) != 'event') {
        // return;
      }
      // set up two fields to store the information
      // these need to have unique names that are different than the acf field names
      $category_field = 'event_category';
      $date_field = 'event_date';
      // delete anything that's currently stored in these two fields
      // to avoid creating duplicates
      delete_post_meta($post_id, $category_field);
      delete_post_meta($post_id, $date_field);
    
      // This is the complicated bit. You need to get the value the
      // category taxonomy field
      // and the date relationship field
      // loop through them, get the value you want to store from those locations
      // and then update the new post meta field with those values
      
          // start loop for a field
          // get value for the field
          add_post_meta($post_id, $field_name, $value, false);
          // false at the end means it can have multiple values
      
    }
    

    Now you can use these fields in WP order by clauses in the meta query to order your event posts by category and date https://make.wordpress.org/core/2015/03/30/query-improvements-in-wp-4-2-orderby-and-meta_query/

    With them in the right order you can loop through them and output new category and date headings when they change.

    Hope some of this helps.

  • The first thing that I would do is store these event dates into something that can more easily be searched in a simple meta_query, like I said above, searches based on repeater sub fields are a PITA that I avoid.

    
    <?php 
      
      // step 1: store event_date in a queryable form
      // this is done as a class, the reason is storage of
      // each value that has been saved
      class store_repeater_sub_field_in_standard_wp_meta {
        
        // this array will store values that have already been saved
        // more about this later
        private $fields = array();
        
        public function __construct() {
          // this is where we add the filters
          // use the field keys here because it is a sub field
          // this class will work on multiple fields by adding the
          // filter multiple times, once for each field key
          // all values stored into new fields will be identical to values stored by ACF
          add_filter('acf/update_value/key=field_123456', array($this, 'convert_sub_field'), 10, 3);
        } // end public function __construct
        
        public function convert_sub_field($value, $post_id, $field) {
          // get the field key
          $field_key = $field['key'];
          // get the field name
          $field_name = $field['name'];
          // create a new field name based on the current field name
          $queryable_name = 'queryable_'.$field_name;
          
          // first step is to see if we've already saved any values for this field
          if (!isset($this->fields[$field_key])) {
            // there is not value set in the property for this key
            // no values have been updated yet
            // clear any existing values from the queryable field
            delete_post_meta($post_id, $queryable_name);
            // add a nested array to the property to hold values
            // for this field, this will also ensure that we don't
            // delete them again since the field has a value in the property
            $this->fields[$field_key] = array();
          }
          // see if we've already saved this value for this field
          // there really is not point saving the same value twice
          if (!in_array($value, $this->fields[$field_key])) {
            // not there, add it the values
            $this->fields[$field_key][] = $value;
            // and add it to the database
            add_post_meta($post_id, $queryable_name, false);
            // the last argument above says that this is not a unique meta key
            // and will hold multiple values
          }
          // return the original value for ACF to process as normal
          return $value;
        } // end public function convert_sub_field
        
      } // end class store_repeater_sub_field_in_standard_wp_meta
      
      // instantiate the object
      new store_repeater_sub_field_in_standard_wp_meta();
      
    ?>
    

    I know that what is above can seem extreme, but this was fairly easy to do (if you remove all the comments there is actually very little code there) and now we can construct extremely simple queries instead of complex LIKE queries and adding filters to add LIKE to the meta_key part of the query because we are querying a sub field.

    
    // current date
    $current_date = date{'Ymd');
    // get the next event from now
    $args = array(
      'post_type' => 'event',
      'post_status' => 'publish',
      'posts_per_page' => 1, // or the number of next dates you want
      'meta_key' => 'queryable_event_date',
      'order_by' => 'meta_value',
      'order' => 'ASC',
      'meta_query' => array(
        'key' => 'queryable_event_date',
        'value' => $date,
        'compare' => '>='
      ),
    );
    $next_event_query = new WP_Query($args);
    

    during the loop for the “next_event” query, collect a list of posts show so that they are not returned in the next query.

    
    // other code before loop
    $events_shown = array();
    if ($next_event_query->have_posts()) {
      while ($next_event_query->have_posts()) {
        $next_event_query->the_post();
        $events_shown[] = $post->ID;
        // other code to display the next event post
      }
      wp_reset_postdata()
    }
    

    Then use the values collected in $events_shown to not get those events again

    
    $args = array(
      'post_type' => 'event',
      'post_status' => 'publish',
      'posts_per_page' => 1, // or the number of next dates you want
      'meta_key' => 'queryable_event_date',
      'order_by' => 'meta_value',
      'order' => 'ASC',
      'meta_query' => array(
        'key' => 'queryable_event_date',
        'value' => $date,
        'compare' => '>='
      ),
      'posts__not_in' => $events_shown,
    );
    $event_query = new WP_Query($args);
    

    I’m sure that you could also construct a single query and loop to do this, but I tend toward a less complex coding style that lets me more easily understand what I was thinking when I need to look at it again in a year because something needs to be changed.

    Hope this helps

  • To answer your question, I’m thinking it would be #2.

    Logically the event_date subfield would have to compare it’s date to today’s date and post the next upcoming event in the left column until that event date has passed. Once that has passed, then the next event date would post in the left column until it’s expiration. All other dates would be posting on the right.

    If ACF is going to be an issue with posting such a repeater in this manner, what would you recommend? A different plugin? A different ACF Field method?

Viewing 25 results - 76 through 100 (of 150 total)