In this example, we’ll assume that our table contains a checkbox field named approved. We want to allow deleting of the record only if that field is not checked (set to 0). If the field is checked (set to 1), it won’t be deleted unless the user is a member of the Admins group.
function tablename_before_delete($selectedID, &$skipChecks, $memberInfo, &$args){
// We’ll perform the ‘approved’ check only if the user
// is not a member of the ‘Admins’ group.
if($memberInfo[‘group’]!=’Admins’){
$id=makeSafe($SelectedID);
$approved=sqlValue(“select `approved` from `tablename` where `id`=’$id'”);
// if the record is approved, don’t allow deleting it
if($approved) return false;
}
return true;
}
Recent Comments