Advertisement
Guest User

theeventscalendargravityforms

a guest
Feb 10th, 2012
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.11 KB | None | 0 0
  1. add_action('save_post', 'save_tec_event_meta_from_gravity', 11, 2);
  2. function save_tec_event_meta_from_gravity($postId, $post) {
  3. if( class_exists('TribeEvents') ) {
  4. // only continue if it's an event post
  5. if ( $post->post_type != TribeEvents::POSTTYPE || defined('DOING_AJAX') ) {
  6. return;
  7. }
  8. // don't do anything on autosave or auto-draft either or massupdates
  9. if ( wp_is_post_autosave( $postId ) || $post->post_status == 'auto-draft' || isset($_GET['bulk_edit']) || $_REQUEST['action'] == 'inline-save' ) {
  10. return;
  11. }
  12.  
  13. if( class_exists('TribeEventsAPI') ) {
  14. $_POST['Organizer'] = stripslashes_deep($_POST['organizer']);
  15. $_POST['Venue'] = stripslashes_deep($_POST['venue']);
  16.  
  17. if( !empty($_POST['Venue']['VenueID']) )
  18. $_POST['Venue'] = array(‘VenueID’ => $_POST['Venue']['VenueID']);
  19.  
  20. if( !empty($_POST['Organizer']['OrganizerID']) )
  21. $_POST['Organizer'] = array(‘OrganizerID’ => $_POST['Organizer']['OrganizerID']);
  22.  
  23. TribeEventsAPI::saveEventMeta($postId, $_POST, $post);
  24. }
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement