Repeating Events don't appear on network

I've setup Events+ on a new site which is a WP Network. I'm not able to get repeating events from network sites to show on the main blog's calendar when using the shortcode [eab_calendar network="yes" navigation="yes"] or the widget with Network-wide checked. Non-repeating events do show on the network calendar.

I found a similar thread at https://premium.wpmudev.org/forums/topic/recurring-event-is-not-displayed-on-network-wide-calendar

I made the changes to /wp-content/plugins/post-indexer/classes/class.model.php as suggested in that thread (I hope the next update incorporates this fix), and then rebuilt the post indexer on Aug 11. The indexer shows over 200 events indexed from one site (only one which is repeating), but it still won't show those repeating events on the network calendar page.

Is there something I'm missing or is this just broken for now? I've granted access with a note of specifics.

Also, I need to customize the appearance of network events to say which site they came from or it's not very helpful.

  • James @ Primal

    Turns out even the Network Upcoming widget is kind of broken with repeating events.
    There is an event that occurs every Wednesday. The next one in the series should be Aug 31, 2016. However, the first event from the series that it's showing is on December 20, 2017; followed by December 27, 2017; January 3, 2018; etc.

    Are repeating events working properly for anyone on a network calendar?

  • Rupok

    Hi Primal Communications, so sorry to hear the inconvenience you are having.

    Before going to change code and other critical stuff, I need to check your events and site configuration. I can see that you enabled Support Access but when trying to login, I'm getting the following error:
    Sorry, this is an invalid access token. You must ask the user to grant access.
    Can you please revoke and grant us permission again so we can have a closer look and try to find out the reason behind this?

    I'm looking forward to hear from you and resolve this issue as soon as possible.

    Have a nice day. Cheers!
    Rupok

  • James @ Primal

    From what I can tell in the Network Upcoming widget code, it's trying to order by event publish date instead of joining the event start date (wp__network_postmeta.incsub_event_start). All the repeating events have the same publish date so they aren't in proper order in the widget. With a limit of 10 total events, only the first few occurrences are shown and they happen to be way in the future. Newly created events may happen to create occurrences in the proper order, but it didn't work like that for me.

    lib/class_eab_network.php:57
    $raw_network_events = $wpdb->get_results("SELECT * FROM {$wpdb->base_prefix}{$pi_table} WHERE post_type='incsub_event' ORDER BY {$pi_published} DESC");

    This appears to also affect the other widgets like the calendar which uses the same piece of code in lib/class_eab_network.php. For example, displaying an August 2016 calendar searches for all events within August 2016, but get_upcoming_events() in lib/class_eab_network.php is returning occurrences from the following year which don't belong to August 2016 and so are not displayed. The occurrences that do fall within August 2016 must be excluded by the limit parameter and are not displayed in calendars.

    All my plugins are up to date according to the dashboard, and I'm kinda surprised no one else has caught this. I might be able to hack my way around it for now, but this seems like a bug for the developer.

    - James

  • James @ Primal

    Here's the code I ended up with for that function at the end of lib/class_eab_network.php. Had to introduce date checks to only get upcoming/in-progress events when not using publish dates, but I also started to get a few empty posts from get_post and had to skip empty events.

    public static function get_upcoming_events ($limit=5) {
    	if (!eab_has_post_indexer()) return array();
    	$limit = (int)$limit ? (int)$limit : 5;
    
    	global $wpdb;
    	$result = array();
    	$count = 0;
    	$pi_table = eab_pi_get_table();
    	$pi_published = eab_pi_get_post_date();
    	$pi_blog_id = eab_pi_get_blog_id();
    	$pi_post_id = eab_pi_get_post_id();
    
    	$now = date('Y-m-d H:i:s');
    
    	$raw_network_events = $wpdb->get_results("
    		SELECT pm.meta_value incsub_event_start,pm1.meta_value incsub_event_end,posts.*
    		FROM {$wpdb->base_prefix}{$pi_table} posts
    		LEFT JOIN {$wpdb->base_prefix}network_postmeta pm ON posts.ID=pm.post_id
    		LEFT JOIN {$wpdb->base_prefix}network_postmeta pm1 ON posts.ID=pm1.post_id
    		WHERE posts.post_type='incsub_event'
    		AND pm.meta_key='incsub_event_start'
    		AND pm1.meta_key='incsub_event_end'
    		AND (
    				pm.meta_value > '{$now}' OR
    				(
    					pm.meta_value < '{$now}' AND
    					pm1.meta_value > '{$now}'
    				)
    			)
    		GROUP BY posts.ID
    		ORDER BY pm.meta_value ASC");
    
    	if (!$raw_network_events) return $result;
    
    	foreach ($raw_network_events as $event) {
    		if ($count == $limit) break;
    		//switch_to_blog($event->$pi_blog_id);
    		//$post = get_post($event->$pi_post_id);
    		$post = get_blog_post($event->$pi_blog_id, $event->$pi_post_id);
    		if(!$post) continue;// Avoid Warning: Creating default object from empty value
    		$tmp_event_instance = new Eab_EventModel($post);
    		$tmp_event_instance->cache_data();
    		if ($tmp_event_instance->is_expired()) continue;
    		$post->blog_id = $event->$pi_blog_id;
    		$result[] = $post;
    		$count++;
    		//restore_current_blog();
    	}
    	return $result;
    }

    I also had a problem with the calendar widget only loading a total of 10 upcoming events, so even though you can page through an unlimited number of months ahead, it would only load a total of 10 starting on the current day. You end up with only a few events at the start of the following month and nothing after. I've had to increase the limit to ensure at least a few months will show.

    lib/widgets/UpcomingCalendar_Widget.class.php: around line 140
    Eab_Network::get_upcoming_events(10)
    I changed the 10 to 200

  • James @ Primal

    Made a fix for blog names not appearing in the calendar widget. Still need to apply to the calendar shortcode. This is partly documentation for me when my custom code is lost in an update.

    lib/class_eab_calendar_helper.php:265

    public function set_event_info ($event_tstamps, $current_tstamps, $event_info) {
    	$this->_titles[] = esc_attr($event_info['title']);
    	$css_classes = $event_info['status_class'];
    	$permalink = isset($event_info['blog_id']) ? get_blog_permalink($event_info['blog_id'], $event_info['id']) : get_permalink($event_info['id']);
    	$tstamp = esc_attr(date_i18n("Y-m-d\TH:i:sO", $event_tstamps['start']));
    	$blog_name = '';
    	if(isset($event_info['blog_id']))
    	{
    		$this_blog = get_blog_details($event_info['blog_id'],false);
    		if(is_object($this_blog))
    			$blog_name = '<span class="blogname">'.$this_blog->blogname.'</span>';
    	}
    	$this->_data[] = '<a class="wpmudevevents-upcoming_calendar_widget-event ' . $css_classes . '" href="' . $permalink . '">' .
    		$event_info['title'] .
    		'<span class="wpmudevevents-upcoming_calendar_widget-event-info"><time datetime="' . $tstamp . '">' .
    			'<var class="eab-date_format-date">' . apply_filters('eab-calendar-upcoming_calendar_widget-start_time', date_i18n(get_option('date_format'), $event_tstamps['start']), $event_tstamps['start'], $event_info['id']) . '</var>' .
    			'</time> ' . $event_info['event_venue'] .
    			$blog_name .
    		'</span>' .
    	'</a>';
    }
  • Kasia Swiderska

    Hello Primal Communications,

    I've checked settings on your site and they are looking good - from what I saw recurring events are showing except this one from Quilting subsite. Can you check if any event from that subsite will show in network calendar? It can be normal event - not recurring.
    This will probably require index rebuilding.

    I was wondering if this could be conflict with another plugin but sites are using the same set of plugins.

    I would like to see however what is in debug log. To enable it, open your wp-config.php file and look for define(‘WP_DEBUG’, false);. Change it to:

    define('WP_DEBUG', true);

    In order to enable the error logging to a file on the server you need to add yet one more similar line:

    define( 'WP_DEBUG_LOG', true );

    In this case the errors will be saved to a debug.log log file inside the /wp-content/directory.

    Depending on whether you want your errors to be only logged or also displayed on the screen you should also have this line there, immediately after the line mentioned above:

    define( 'WP_DEBUG_DISPLAY', false );

    The wp-config.php is located in your WordPress root directory. It’s the same file where the database configuration settings are. You will have to access it by FTP or SFTP in order to edit it. I would need then to see contents of the debug.log file - so please paste it to the text file and attach to post.

    kind regards,
    Kasia

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.