I've this scenario and I don't know if it's achievable:
I should ensure some users (U1, U2, U3...) can create/edit nodes under a "News" parent node, but I don't want U1 to see/edit the nodes created by other users.
Every user should see/edit the nodes he has created himself.
Is this behaviour achievable?
public class UmbracoBootstrapper : ApplicationEventHandler
{
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication,
ApplicationContext applicationContext)
{
// register the event listener:
TreeControllerBase.TreeNodesRendering += TreeControllerBase_TreeNodesRendering;
}
void TreeControllerBase_TreeNodesRendering(TreeControllerBase sender, TreeNodesRenderingEventArgs e)
{
var cs = ApplicationContext.Current.Services.ContentService;
//filter by tree type and by user type
if (sender.TreeAlias == "content" && sender.Security.CurrentUser.UserType.Alias != "admin")
{
//remove all nodes not created by the current user
e.Nodes
.RemoveAll(x =>
cs.GetById(int.Parse(x.Id.ToString()))?.CreatorId != sender.Security.CurrentUser.Id
&&
x.AdditionalData.Select(y => y.Key).Contains("contentType")
&&
x.AdditionalData["contentType"].ToString() == "page"
);
}
}
}
User permission: show only "Created by ME" nodes
Hi everyone!
I've this scenario and I don't know if it's achievable:
I should ensure some users (U1, U2, U3...) can create/edit nodes under a "News" parent node, but I don't want U1 to see/edit the nodes created by other users.
Every user should see/edit the nodes he has created himself. Is this behaviour achievable?
Thank you
S
@Stefano Beretta,
Did u solve this puzzle. As we have same requirement. If you solved this, Can you please help me.
Thank you.
Hi Suman!
Yes, I did it! :D
In the
ApplicationStarted
you can register a specific eventTreeControllerBase.TreeNodesRendering
and then manipulate the event args (the nodes).Here's the topic where I found the code
and here's my code (tested on Umbraco 7.14+):
I hope that's what you need :D
S
Hi Stefano Beretta,
Good Afternoon...!
Thank you very much for your reply. It worked for me also.
You saved a lot of time.
is working on a reply...