Hello all,
I have a module where I need to be able to add all of the users currently in "RoleA" to "RoleB". I have code for adding users to a role no problem. I have the code to get a arraylist of all users currently in a role. I need help understanding how to put the two together. How can I have the AddUserRole fire for each user in the original role?
Here is what I have so far.
Dim roleCtlr As New DotNetNuke.Security.Roles.RoleController
Dim objUserRoles As ArrayList = roleCtlr.GetUserRolesByRoleName(PortalId, roleName)
Got the array list of users in "roleName" Now how do I implement the code below to run on each user in the array list?
Dim objRoles As New RoleController()
Dim UserName1 As String = ""
Dim user As UserInfo = UserController.GetUserByName(Me.PortalId, UserName1)
Dim userId As Integer = user.UserID
Dim objRoleController As New DotNetNuke.Security.Roles.RoleController
Dim objRoleInfo As DotNetNuke.Security.Roles.RoleInfo = objRoleController.GetRoleByName(PortalId, AddVideo)
If objRoleInfo Is Nothing Then
selected1.Text = (selectedRole & " is not currently a member of *****.com.")
selected2.Text = ("Ask them to sign up for a free account.")
End If
Dim effectiveDate As DateTime = DateTime.Now
objRoleController.AddUserRole(PortalId, user.UserID, objRoleInfo.RoleID, effectiveDate, effectiveDate.AddDays(7.0#))
DotNetNuke.Common.Utilities.DataCache.ClearUserCache(PortalId, user.Username)
For the next step of what I am doing. I also need to be able to get the email address for each of those users. How can I also pull that info from the array list.
Thanks in advance!