Copied to clipboard

Flag this post as spam?

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


  • lori ryan 239 posts 573 karma points
    Jan 28, 2021 @ 12:07
    lori ryan
    0

    permissions - dont allow editing of homepage.

    How do I stop users from editing the homepage. When I apply the browse permissions all subpages are also affected.

  • lori ryan 239 posts 573 karma points
    Feb 18, 2021 @ 16:32
    lori ryan
    0

    anybody??? please

  • Welton Ferreira 2 posts 72 karma points
    Feb 18, 2021 @ 17:12
    Welton Ferreira
    0

    The browse permission only allows the user to view the node (and its children), have you tried removing the Update permission?

  • lori ryan 239 posts 573 karma points
    Mar 05, 2021 @ 11:33
    lori ryan
    0

    Hi Welton the issue is its affecting all nodes - then I have to go to all children of home and add the update permission.

  • James Shelley 9 posts 103 karma points
    Feb 26, 2021 @ 16:00
    James Shelley
    1

    You could use a custom save event composer to not allow users to save any content on the homepage. You could just allow your email to save the homepage.

    using Umbraco.Core;
    using Umbraco.Core.Composing;
    using Umbraco.Core.Events;
    using Umbraco.Core.Models.Membership;
    using Umbraco.Core.Services;
    using Umbraco.Core.Services.Implement;
    using Umbraco.Web;
    using Umbraco.Web.Security;
    
    namespace UmbracoBuild.Composers
    {
        [RuntimeLevel(MinLevel = RuntimeLevel.Run)]
        public class SavingEventComposer : ComponentComposer<SavingEventComponent>
        { }
    
        public class SavingEventComponent : IComponent
        {
            private readonly IUmbracoContextFactory _umbracoContextFactory;
    
            public SavingEventComponent(IUmbracoContextFactory umbracoContextFactory)
            {
                _umbracoContextFactory = umbracoContextFactory;
            }
    
            public void Initialize()
            {
                ContentService.Saving += ContentService_Saving;
            }
    
            private void ContentService_Saving(IContentService sender, ContentSavingEventArgs e)
            {
                IUser currentUser = null;
    
                foreach (var node in e.SavedEntities)
                {
                    using (UmbracoContextReference umbracoContextReference = _umbracoContextFactory.EnsureUmbracoContext())
                    {
                        var userTicket = umbracoContextReference.UmbracoContext.HttpContext.GetUmbracoAuthTicket();
                        if (userTicket != null)
                        {
                            currentUser = Current.Services.UserService.GetByUsername(userTicket.Identity.Name);
                        }
    
                        //your homepage node
                        if (node.ContentType.Alias == "homePage" && node.Id > 0)
                        {
                            //only allow your username to save the homepage
                            if(currentUser.Username != "your_username_here")
                            {
                                e.Cancel = true;
                                e.CancelOperation(new EventMessage("Error", "You do not have the permissions to save this page.", EventMessageType.Error));
                            }
    
                        }
                    }
                }
            }
    
            public void Terminate()
            {
            }
        }
    }
    
  • 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.

Please Sign in or register to post replies