How to auto blog an external feed into a group calendar plugin

I have a lot of events I need to add into the group calendar plugin. The data will be coming from external sites. Can I set up auto blog to load these items for me? If not, is there a batch db upload I can do for these items?

  • Philip John

    Hiya!

    BP Group Calendar currently works on custom database tables as opposed to custom post types which means that it doesn't integrate with Autoblog.

    However, if you're at all comfortable with development take a look at lines 310-330 of bp-group-calendar/groupcalendar/bp-group-calendar.php which is the code that deals with inserting new events into the database. It's this bit:

    ...
    			$query = $wpdb->prepare("INSERT INTO " . $wpdb->base_prefix . "bp_groups_calendars
                                	( group_id, user_id, event_time, event_title, event_description, event_location, event_map, created_stamp, last_edited_id, last_edited_stamp )
                                	VALUES ( %d, %d, %s, %s, %s, %s, %d, %d, %d, %d )",
    			$group_id, $current_user->ID, $event_date, $event_title, $event_description, $event_location, $event_map, time(), $current_user->ID, time() );
    
    			if ($wpdb->query($query)) {
    				bp_core_add_message( __("Event saved", 'groupcalendar') );
    				bp_group_calendar_event_add_action_message(true, $wpdb->insert_id, $event_date, $event_title);
    
    				//email group members
    				bp_group_calendar_event_email(true, $wpdb->insert_id, $event_date, $event_title);
    
    				return true;
    			} else {
    				bp_core_add_message( __("There was a problem saving to the DB", 'groupcalendar'), 'error' );
    				return false;
    			}
    ...

    You should be able to figure out from that fairly easily how to create a short script that can run through a list of your events and add them to the database directly.

    Cheers!
    Phil