I've created a gist on how you'd go about doing this. It's a bit easier than using the code formatter here on our.
Just to run through the code. This event fires on Published, but you could also use Saved if you'd prefer. I refactored the code to work with an IEnumerable
Once passed in the PublicAccessService checks if the current IContent is protected and gets the entries for it.
If it has any rules of type MemberGroup then we can proceed and get the members of that group using the MemberService.
Once we have the members we can get their email and that's where your code comes in to send them an email using their email.
If this helped please mark it as the accepted answer. :)
Just saw your additional requirements above and I've updated the gist to also check if the group value is valid in a static list of group names.
As a user could belong to multiple groups I call Distinct() to ensure the members being passed in are unique. This is all coding logic though and can be changed to your future requirements. At this point the mystery of how to get members for a specific page being saved is unravelled :)
It's true member groups aren't additive. You may need to rethink your security model in order to get around this. :/
That's definitely a different question, I'd probably encourage you to start a new ticket and close off this one so people aren't confused by the topic title :)
Other than that, if my answers help you get a little bit closer to where you want to be. Could you mark it as the answer even if it only answers one of the requirements (email sending)?
Get All Members with acces to content
Hi
I there are way to get all members there have access to the content
Hi Amalie,
Could you possibly provide a bit more context to your question? :)
Where & how are you trying to access these members?
Is the data required to be used on a per page basis?
Is it protected by the Umbraco Public Access feature by a member group?
Finally what version of Umbraco are you using (7.2.x, 7.3.x, 7.4.x)?
Thanks,
Jamie
Hi Jamie
Its on a publish event. where i want to send a notification to the members who has access to the current file or Node.
I have a structure like
So i want to send the notification to all members who has membergroup 1 or 2 and also membergroup A -just a bit more complex
And its umbraco 7.4.3
And these are Members rather than backoffice Users?
Yes its members
I've created a gist on how you'd go about doing this. It's a bit easier than using the code formatter here on our.
Just to run through the code. This event fires on Published, but you could also use Saved if you'd prefer. I refactored the code to work with an IEnumerable
Once passed in the PublicAccessService checks if the current IContent is protected and gets the entries for it.
If it has any rules of type MemberGroup then we can proceed and get the members of that group using the MemberService.
Once we have the members we can get their email and that's where your code comes in to send them an email using their email.
If this helped please mark it as the accepted answer. :)
Thanks,
Jamie
Just saw your additional requirements above and I've updated the gist to also check if the group value is valid in a static list of group names.
As a user could belong to multiple groups I call Distinct() to ensure the members being passed in are unique. This is all coding logic though and can be changed to your future requirements. At this point the mystery of how to get members for a specific page being saved is unravelled :)
Hi again
It looks great.
I just realised that the member rights doesnt work as i expected
I wanted it to only allow members with both membergroup 1 and membergroup a
Not all members with 1 and A
Hi Amalie,
It's true member groups aren't additive. You may need to rethink your security model in order to get around this. :/
That's definitely a different question, I'd probably encourage you to start a new ticket and close off this one so people aren't confused by the topic title :)
Other than that, if my answers help you get a little bit closer to where you want to be. Could you mark it as the answer even if it only answers one of the requirements (email sending)?
Thanks,
Jamie
Hi Jamie
I found another solution for this.
The method i asked for was a simpel way to get all members with access Something like this Content.GetAllAllowedMembers();
I had already done something like you suggested.
Thank you for the help - i haven't tried your solution. - I will mark your answer as a solution and hopes it works and will help some one else
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.