The onBeforeDelete handler is used for when an editor tries to delete a piece of content, but before LiveWhale deletes it, you can perform your own custom validation.
To add a validation check, you can look the item up by $id and/or add error messages to the $_LW->REGISTERED_MESSAGES['failure']
array as needed.
<?php
$_LW->REGISTERED_APPS['my_app']=[
'title'=>'My App',
'handlers'=>['onBeforeDelete'],
];
class LiveWhaleApplicationMyApp {
public function onBeforeDelete($data_type, $id) {
global $_LW;
if ($data_type=='events') {
$data = $_LW->read($data_type, $id);
if ($data['gid']=2 && !$_LW->userSetting('core_admin')) {
$_LW->REGISTERED_MESSAGES['failure'][]='Only admins are permitted to delete events from this group.';
};
};
}
}
?>