I would like to log when a role is added or removed for a user.
But none of these methods are being triggered on such use cases.
patch.config:
<sitecore>
<events>
<event name="roles:usersAdded">
<handler type="MyCode.AccountEventHandler, MyCode" method="OnRoleAddedForUser"/>
</event>
<event name="roles:usersRemoved">
<handler type="MyCode.AccountEventHandler, MyCode" method="OnRoleRemovedForUser"/>
</event>
<event name="user:runtimerolesupdated">
<handler type="MyCode.AccountEventHandler, MyCode" method="OnUserRuntimeRolesUpdated"/>
</event>
<event name="user:updated">
<handler type="MyCode.AccountEventHandler, MyCode" method="OnUserUpdated"/>
</event>
</events>
</sitecore>
AccountEventHandler.cs
protected void OnRoleAddedForUser(object sender, EventArgs args)
{
Log.Info("Role added for user");
}
protected void OnRoleRemovedForUser(object sender, EventArgs args)
{
Log.Info("Role removed for user");
}
protected void OnUserRuntimeRolesUpdated(object sender, EventArgs args)
{
Log.Info("Role updated for user");
}
protected void OnUserUpdated(object sender, EventArgs args)
{
Log.Info("user updated");
}
I have extended other events like user:created
& user:deleted
. They work fine.