« All Handlers

onBeforeDelete

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.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<?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.';
};
};

}

}
?>