Here is the relevant code (it's almost identical for all 3) in case the issue is here.
public override void ItemDeleting(SPItemEventProperties properties)
{
base.ItemDeleting(properties);
using (SPSite site = new SPSite(properties.WebUrl))
{
using (SPWeb web = site.OpenWeb())
{
int _currentUser = properties.CurrentUserId;
SPUser spCurrentUser = web.SiteUsers.GetByID(_currentUser);
if (spCurrentUser.IsSiteAdmin == true)
{
properties.Cancel = false;
properties.Status = SPEventReceiverStatus.Continue;
}
else
{
properties.Cancel = true;
properties.ErrorMessage = "Past registrations can only be deleted by a site administration";
}
}
}
No comments:
Post a Comment