Skip to main content
added 86 characters in body
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

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.

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 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.

added 657 characters in body
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

I would like to log when a role is added or removed for a user.

But
But none of these methods are not 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 would like to log when a role is added or removed for a user.

But these methods are not being triggered.

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>
  </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");
        }

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");
        }
Source Link
sukesh
  • 3.3k
  • 3
  • 29
  • 78

Which event to extend when a role is added to user

I would like to log when a role is added or removed for a user.

But these methods are not being triggered.

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>
  </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");
        }