Advertisement
Guest User

Untitled

a guest
Nov 16th, 2011
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.04 KB | None | 0 0
  1. // Format Date from gravity forms to events plugin
  2. add_action("gform_pre_submission_6", "format_event_data");
  3.  
  4. function format_event_data($form){
  5.     $formId = 6;  // this is the gravity forms id
  6.     $startDate = 3; // this is the form element that contains the date  of the form 'mm/dd/yyyy'  $_POST['input_3']
  7.     $endDate = 4;// this is the form element that contains the date  of the form 'mm/dd/yyyy'  $_POST['input_3']
  8.     $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
  9.     $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
  10.    
  11.     if($form["id"] != $formId){
  12.         return;
  13.     }
  14.     $startDate = date_parse($_POST['input_'. $startDate]); // break the date into an array
  15.     $endDate = date_parse($_POST['input_'. $endDate]); // break the date into an array
  16.     // sql format the result
  17.     $startDate = $startDate['year'] . '-' . str_pad($startDate['month'], 2, "0", STR_PAD_LEFT) . '-' . str_pad($startDate['day'], 2, "0", STR_PAD_LEFT);
  18.     $endDate = $endDate['year'] . '-' . str_pad($endDate['month'], 2, "0", STR_PAD_LEFT) . '-' . str_pad($endDate['day'], 2, "0", STR_PAD_LEFT);
  19.  
  20.     // get the start/end times
  21.     $startTime = $_POST['input_'. $startTimeFormId];
  22.     $endTime = $_POST['input_'. $endTimeFormId];
  23.  
  24.     // load the values for EventsCalendarPro
  25.     $_POST['EventStartDate'] = $startDate;
  26.     $_POST['EventStartHour'] = str_pad($startTime[0], 2, "0", STR_PAD_LEFT);
  27.     $_POST['EventStartMinute'] = str_pad($startTime[1], 2, "0", STR_PAD_LEFT);
  28.     $_POST['EventStartMeridian'] = $startTime[2];
  29.    
  30.     $_POST['EventEndDate'] = $endDate;
  31.     $_POST['EventEndHour'] = str_pad($endTime[0], 2, "0", STR_PAD_LEFT);
  32.     $_POST['EventEndMinute'] = str_pad($endTime[1], 2, "0", STR_PAD_LEFT);
  33.     $_POST['EventEndMeridian'] = $endTime[2];
  34.    
  35.     $organizerID = 16;
  36.     $organizerName = 11;
  37.     $organizerEmail = 12;
  38.     $organizerPhone = 13;
  39.     $organizerWebsite = 14;
  40.    
  41.     if( $_POST['input_'. $organizerID] != 'Add New Entry') {
  42.         $_POST['organizer']['OrganizerID'] = $_POST['input_'. $organizerID];
  43.     } else {
  44.         // Organizer Population
  45.         $_POST['organizer']['Organizer'] = $_POST['input_' . $organizerName];
  46.         $_POST['organizer']['Phone'] = $_POST['input_' . $organizerPhone];
  47.         $_POST['organizer']['Website'] = $_POST['input_'. $organizerWebsite] == 'http://' ? '' : $_POST['input_'. $organizerWebsite];
  48.         $_POST['organizer']['Email'] = $_POST['input_' . $organizerEmail];
  49.     }
  50.    
  51.     $venueID = 7;
  52.    
  53.     if( $_POST['input_'. $venueID] != 'Add New Entry') {
  54.         $_POST['venue']['VenueID'] = $_POST['input_'. $venueID];
  55.     } else {
  56.         // Venue Population
  57.         $_POST['venue']['Venue'] = $_POST['input_8'];
  58.         $_POST['venue']['Country'] = 'Canada';
  59.         $_POST['venue']['Address'] = $_POST['input_9.1'];
  60.         $_POST['venue']['City'] = $_POST['input_9.3'];
  61.         $_POST['venue']['StateProvince'] = 'ON';
  62.         $_POST['venue']['Zip'] = $_POST['input_9.5'];
  63.     }
  64.  }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement