Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Format Date from gravity forms to events plugin
- add_action("gform_pre_submission_6", "format_event_data");
- function format_event_data($form){
- $formId = 6; // this is the gravity forms id
- $startDate = 3; // this is the form element that contains the date of the form 'mm/dd/yyyy' $_POST['input_3']
- $endDate = 4;// this is the form element that contains the date of the form 'mm/dd/yyyy' $_POST['input_3']
- $startTimeFormId = 5; // form element for the start time $_POST['input_4'][0] - for hour, $_POST['input_4'][1] - for minute, $_POST['input_4'][2] - for meridian
- $endTimeFormId = 6; // form element for the start time $_POST['input_5'][0] - for hour, $_POST['input_5'][1] - for minute, $_POST['input_5'][2] - for meridian
- if($form["id"] != $formId){
- return;
- }
- $startDate = date_parse($_POST['input_'. $startDate]); // break the date into an array
- $endDate = date_parse($_POST['input_'. $endDate]); // break the date into an array
- // sql format the result
- $startDate = $startDate['year'] . '-' . str_pad($startDate['month'], 2, "0", STR_PAD_LEFT) . '-' . str_pad($startDate['day'], 2, "0", STR_PAD_LEFT);
- $endDate = $endDate['year'] . '-' . str_pad($endDate['month'], 2, "0", STR_PAD_LEFT) . '-' . str_pad($endDate['day'], 2, "0", STR_PAD_LEFT);
- // get the start/end times
- $startTime = $_POST['input_'. $startTimeFormId];
- $endTime = $_POST['input_'. $endTimeFormId];
- // load the values for EventsCalendarPro
- $_POST['EventStartDate'] = $startDate;
- $_POST['EventStartHour'] = str_pad($startTime[0], 2, "0", STR_PAD_LEFT);
- $_POST['EventStartMinute'] = str_pad($startTime[1], 2, "0", STR_PAD_LEFT);
- $_POST['EventStartMeridian'] = $startTime[2];
- $_POST['EventEndDate'] = $endDate;
- $_POST['EventEndHour'] = str_pad($endTime[0], 2, "0", STR_PAD_LEFT);
- $_POST['EventEndMinute'] = str_pad($endTime[1], 2, "0", STR_PAD_LEFT);
- $_POST['EventEndMeridian'] = $endTime[2];
- $organizerID = 16;
- $organizerName = 11;
- $organizerEmail = 12;
- $organizerPhone = 13;
- $organizerWebsite = 14;
- if( $_POST['input_'. $organizerID] != 'Add New Entry') {
- $_POST['organizer']['OrganizerID'] = $_POST['input_'. $organizerID];
- } else {
- // Organizer Population
- $_POST['organizer']['Organizer'] = $_POST['input_' . $organizerName];
- $_POST['organizer']['Phone'] = $_POST['input_' . $organizerPhone];
- $_POST['organizer']['Website'] = $_POST['input_'. $organizerWebsite] == 'http://' ? '' : $_POST['input_'. $organizerWebsite];
- $_POST['organizer']['Email'] = $_POST['input_' . $organizerEmail];
- }
- $venueID = 7;
- if( $_POST['input_'. $venueID] != 'Add New Entry') {
- $_POST['venue']['VenueID'] = $_POST['input_'. $venueID];
- } else {
- // Venue Population
- $_POST['venue']['Venue'] = $_POST['input_8'];
- $_POST['venue']['Country'] = 'Canada';
- $_POST['venue']['Address'] = $_POST['input_9.1'];
- $_POST['venue']['City'] = $_POST['input_9.3'];
- $_POST['venue']['StateProvince'] = 'ON';
- $_POST['venue']['Zip'] = $_POST['input_9.5'];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement