Created
April 24, 2024 15:53
-
-
Save warrenbuckley/e6d78665926b34f7376dd8bcbf1cb051 to your computer and use it in GitHub Desktop.
Umbraco: Add a NEW member group to all members who do not have the group already assigned
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Variables -- | |
DECLARE @memberGroup VARCHAR(100) = 'PORTAL MEMBER' | |
DECLARE @memberGroupIntId INT | |
DECLARE @nodeId INT | |
-- Get the INT ID of the member group that is called 'Portal Member' -- | |
SELECT @memberGroupIntId = [id] | |
FROM [dbo].[umbracoNode] | |
WHERE nodeObjectType = '366E63B9-880F-4E13-A61C-98069B029728' -- This GUID is for member groups -- | |
AND UPPER(Text) = UPPER(@memberGroup) | |
-- Add all members not in the group, to the group | |
INSERT INTO [cmsMember2MemberGroup] ([Member], [MemberGroup]) | |
SELECT [NodeId],@memberGroupIntId | |
FROM [cmsMember] | |
WHERE nodeId NOT IN ( | |
SELECT [Member] | |
FROM [cmsMember2MemberGroup] | |
WHERE [MemberGroup] = @memberGroupIntId) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment