How to Create a GroupUserAdded() SPSecurityEventReceiver in SharePoint 2013
when a triggering action like adding, deleting, updating, moving, checking in and checking out occurs on any specified object of SharePoint, an event receiver is called up. Sharepoint has introduced a new event receiver known class known as SPSecurityEventReceiver.
Now, find out how you can create a group user added event receiver through this. We will do this by creating a custom list called “group details” whenever a user joins the group.
Add a new Class file “UserAddedEventReceiver.cs” to your project.
Step 7 – Make sure that your class inherits SPSecurityEventReceiver class. Add the following Code for GroupUserAdded() in your UserAddedEventReceiver class.
class UserAddedEventReceiver : SPSecurityEventReceiver
public override void GroupUserAdded(SPSecurityEventProperties properties)
//Get the user being added
SPUser addedUser = properties.Web.AllUsers.GetByID(properties.GroupUserId);
if (addedUser != null && properties.GroupId == 8)
SPGroup spGroup = properties.Web.Groups[“Added Members”];
if (spGroup != null)
The code should look something like below.
Step 8 – Once the code is added Start and debug the project.The project will add the solution in your site and activate the feature as well. Feature activation will kick off the Feature Receiver and registers the GroupUserAdded() events.
Step 9 – Once the solution is deployed verify if the Feature is activated.To do this navigate to your SharePoint site -> Settings -> Manage site Features. In the feature list look for “GroupUserAddedEventReceiver Feature 1″ feature.
Step 10 – Now Navigate to the People and groups -> Team Site Members to add a new user. Follow the screens below –
Select New -> “Add Users to this group”.
- QuickBooks2016.07.01QuickBooks 2016 : How to Select the Industry Type and Accounts
- Microsoft Sharepoint2016.06.30Microsoft’s SharePoint 2016: Awesome New Features Added For It’s Users
- QuickBooks2016.06.27How To Search and Edit Customers Records In QuickBooks 2016
- Microsoft Sharepoint2016.06.22Microsoft Announces Release Of iOS App For SharePoint