Support

Home Forums Event Espresso Premium Recurring Events opens closed events – workaround

Recurring Events opens closed events – workaround

Posted: September 12, 2013 at 10:24 am

Viewing 0 reply threads


thinkbiglearnsmart

September 12, 2013 at 10:24 am

I had a previous forum post that’s closed now, but I wanted to post my solution in case others have the same issue. Original post:
https://eventespresso.com/topic/recurring-events-opens-closed-events/

I ended up adding a checkbox to the Event Options box to control whether the status (Active or Inactive) is applied to all events in the series when that choice is selected for the event update.

Then I modified the update_event function so the event active status is only affected when the new checkbox is checked.

In the database, I set all old/passed events as not active.

in file–event-espresso/includes/admin-files/event-management/advanced_settings.php
approx. after line 47 'Is this an active event?', add the following:
[code language=”php”]
/*========= Add checkbox to Event Options ===========*/
/*
* This checkbox only works when main "All events in series" is selected
*/

/*———– MOD BEGIN ———–*/
//Add checkbox to Event Options
if (defined(‘EVENT_ESPRESSO_RECURRENCE_TABLE’) && $recurrence_id > 0) {
$advanced_options .= ‘<input name=”rd_apply_status_to_all_events” type=”checkbox” value=”1″ /> ‘.__(‘Apply active status to all events in series’, ‘event_espresso’);
}
/*———– MOD END ———–*/
[/code]
in file–event-espresso/includes/event-management/update_event.php
replace approx. line 357 with commented out version – to remove active listing from SQL update
[code language=”php”]

/*======= Change Event Update Behavior =========*/

//’is_active’ => $is_active, //MOD

[/code]
replace $sql_data with new one line 381-390 to comment out $sql_data and replace
[code language=”php”]

/*———– MOD BEGIN ———–*/

/* $sql_data = array(‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’,
‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’,
‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%d’, ‘%d’, ‘%d’, ‘%d’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%d’);*/

$sql_data = array(‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’,
‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’,
‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%d’, ‘%d’, ‘%d’, ‘%d’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%s’, ‘%d’);

/*———– MOD END ———–*/
[/code]
add around line 470, between Staff and Venues
[code language=”php”]

/*———– MOD BEGIN ———–*/

//Active Event

if (isset($_POST[‘rd_apply_status_to_all_events’]) && $_POST[‘recurrence_apply_changes_to’] == 2){
//Update all events
$wpdb->update(
EVENTS_DETAIL_TABLE,
array(
‘is_active’ => $is_active
),
array(‘id’ => $event_id),
array( ‘%s’),
array( ‘%d’ )
);
} else if ($_POST[‘event_id’] == $event_id){
//Just update single event
$sql_status = “UPDATE ” . EVENTS_DETAIL_TABLE . ” SET is_active = ‘”.$is_active.”‘ WHERE id = ‘” . $event_id . “‘”;
$wpdb->query($wpdb->prepare($sql_status, NULL));
}

/*———– MOD END ————-*/
[/code]

Viewing 0 reply threads

The support post ‘Recurring Events opens closed events – workaround’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso