Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Gurumurthy 54 posts 127 karma points
    Mar 19, 2021 @ 11:35
    Gurumurthy
    0

    Can we programmatically add an member to specific node? to restrict public access.

    Hi All,

    can we restrict public access for an node to with specific members programmatically ?

    enter image description here

    Any help on this would be much appreciated. Umbarco v8.11

    Thanks, Gurumurthy J V

  • Marc Goodson 2155 posts 14408 karma points MVP 9x c-trib
    Mar 20, 2021 @ 07:46
    Marc Goodson
    0

    Hi Gurumurthy

    I'm not super sure but there is a core service called PublicAccessService which you can use to programatically set PublicAccessRules on particular content items.

    https://github.com/umbraco/Umbraco-CMS/blob/ece7008ce716029111452c80233b251802947e31/src/Umbraco.Core/Services/Implement/PublicAccessService.cs

    Would that be what you are after

    var publicAccessService = Services.PublicAccessService;
    

    if you are inheriting from a special 'Umbraco' base class, eg SurfaceController, RenderMvcController etc

    or you can inject IPublicAccessService via dependency injection into the constructor of a custom class.

    regards

    Marc

Please Sign in or register to post replies

Write your reply to:

Draft