Custom Event not working

Hi I am developing a plug-in i need that when user will be created at a specific email condition user should be addeded into a custom role but my code is not working

private void Events_AfterCreate(UserAfterCreateEventArgs e)
{

Apis.Get<IRoleUsers>().AddUserToRole(
new RoleUserCreateOptions() { UserId = e.Id, RoleId = 19 }
);

}

what is the wrong with this code.

Parents Reply Children