Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Sample LiveWhale event creation code
<?php
// Sample event creation code
require $_SERVER['DOCUMENT_ROOT'].'/livewhale/nocache.php'; // load LW functions
$gid = 1; // id of group where the event should be created
$data_to_save = array( // create sample event
'gid'=>$gid,
'title'=>'Sample Event',
'status'=>2, // 1 = live, 2 = hidden
'date'=>$_LW->toDate('m/d/Y', $_LW->toTS('+1 month')), //start date
'date2'=>'', // end date
'date_time'=>'', // start time (leave blank for all day)
'date2_time'=>'', // end time
'is_all_day'=>1, // set to 1 for all day
'timezone'=>'America/New_York',
'categories'=>array(1,2,3), // array of event type IDs
'associated_data'=>array(
'tags'=>array('demo'),
'images'=>array(
array(
'path'=>$_LW->LIVEWHALE_DIR_PATH.'/start/images/whale.jpg',
'description'=>'Whale',
'date'=>$_LW->toDate('m/d/Y'),
'caption'=>'Photo of a whale.',
'is_thumb'=>1,
'only_thumb'=>'',
'full_crop'=>'',
'full_src_region'=>'',
'thumb_crop'=>1,
'thumb_src_region'=>''
)
)
)
);
if ($id=$_LW->create('events', $data_to_save)) {
echo 'Created event '.$id.'<br/>';
}
else {
print_r($data_to_save);
echo $_LW->error.'<br/>';
};
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment