Hello,
There is no UserID for the E-commerce customers; there is only the CustomerID which has no relation to the actual UserID since users and customers are two separate objects. You can use the methods below to delete both the Customer and the User records for a given user which doesn’t rely on there ID.
private bool DeleteCustomer()
{
// Prepare the parameters
string where = "CustomerLastName LIKE N'My New%'";
// Delete user
UserInfo user = UserInfoProvider.GetUserInfo("My new user");
UserInfoProvider.DeleteUser(user);
// Get the data
DataSet customers = CustomerInfoProvider.GetCustomers(where, null);
if (!DataHelper.DataSourceIsEmpty(customers))
{
foreach (DataRow customerDr in customers.Tables[0].Rows)
{
// Create object from DataRow
CustomerInfo deleteCustomer = new CustomerInfo(customerDr);
// Delete the customer
CustomerInfoProvider.DeleteCustomerInfo(deleteCustomer);
}
return true;
}
return false;
}
private bool DeleteUser()
{
// Get the user
UserInfo deleteUser = UserInfoProvider.GetUserInfo("MyNewUser");
// Delete the user
UserInfoProvider.DeleteUser(deleteUser);
return (deleteUser != null);
Otherwise, you could consider using the ObjectEvents.Delete.Before event instead of the UserInfo.TYPEINFO.Events.Delete.Before event as you have planned, since both the User and Customer are objects. The CustomerUserID should still be available in this handler.