Skip to content

Instantly share code, notes, and snippets.

@karlhinze
Last active April 15, 2020 18:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save karlhinze/c2ac91aa1dcc4732e22d5e4b3fd2474a to your computer and use it in GitHub Desktop.
Save karlhinze/c2ac91aa1dcc4732e22d5e4b3fd2474a to your computer and use it in GitHub Desktop.
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