Support » Plugin: Church Community Builder Core API » Recurring Events

  • Resolved sus


    Hi Jared,

    In your sample code on Github, I see the following statement:

    IMPORTANT: Recurring events in CCB are actually just a single event with a calculated recurrence that is output to the public_calendar_listing service. Therefore we are going to have multiple *instances* of each event and we should not download an event’s image multiple times…

    As a church, we have, Sunday services, which are recurring. However, when they are imported they are imported as individual events.

    How are they linked to one another as “recurring” events?

    • This topic was modified 2 years, 2 months ago by sus.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Jared Cobb


    Hi Susan,

    Great question. This is one of the more confusing aspects of the public_calendar_listing service. When a recurring event is created in CCB it’s actually stored as a single record in the database and includes the “rules” for when the event repeats.

    However the CCB API does not expose those rules. Instead, they dynamically generate instances of each occurrence. Think of the recurring event (in CCB) as a blueprint, and then the public_calendar_listing service just “stamps out” multiple copies of that event that occur during the date range.

    Luckily the public_calendar_listing service does inject the original event id in their XML response like so:

    	<event_name ccb_id="1234">Sunday Service</event_name>
    	<event_description>This is our weekly Sunday Service event</event_description>

    Notice the ccb_id is an attribute on the event_name node. Each occurrence of this event will have the same ccb_id (even though the date will be different for each one).

    It definitely makes sense to have this id available to you in WordPress so I published a new version of the plugin today that makes this possible.

    Starting in version 1.0.4 each instance of a recurring event (in WordPress) will have the event_id stored as post meta on the post. This allows you to do a couple of things right off the bat…

    1) You can now write your own custom WP_Query loop and get all occurrences of a specific event like so:

    // WP_Query arguments that allow you to get
    // all instances of the event with an id of 1234
    $args = array(
    	'post_type' => array( 'ccb_core_calendar' ),
    	'meta_query' => array(
    			'key' => 'event_id',
    			'value' => '1234',
    			'compare' => '=',
    			'type' => 'NUMERIC',
    // Query WordPress then you can enter the loop
    $query = new WP_Query( $args );

    This might be useful if you wanted to create an area in your single event template to show “Upcoming occurrences of this event”…

    2) If you have a specific instance of an event you can get the event id and perform any other actions (maybe you want to call the event_profile service) like so:

    $event_id = get_post_meta( get_the_ID(), 'event_id', true);
    // Now do something with the $event_id like call a different CCB API service

    Just to sum up and answer your question, now in version 1.0.4 events are “linked” to one another by this new post meta key event_id.

    One final note: You will need to delete all the instances of the events in WordPress and then re-synchronize in order to get the updated post meta.

    Wow Jared this is great! Thanks for adding this feature to the plugin!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Recurring Events’ is closed to new replies.