asilentwish Posted June 4, 2018 Share Posted June 4, 2018 Hello, I'm new to the forum and was wondering how to do the following: I have created a role for certain users who are only allowed to edit their own pages. I created a module which list only their pages. public function viewable(HookEvent $event) { if(!$event->return) return; $page = $event->object; if($this->user->name !== $page->createdUser->name && $page->id != 1 && $page->id != 1046) $event->return = false; } The superuser sees this: Home - Page --Subpage 01 --Subpage 02 --Subpage 03 --Subpage 04 --Subpage 05 The specific user sees this: Home - Page --Subpage 02 --Subpage 05 This works just fine. But when I'm logged in as a specific user I still see all the pages in the submenu and can still edit them. I don't want this. Is it possible to remove all the other pages and only show the pages that the logged in user created? Is is also possible to remove them from the search results when I'm logged in with specific role? Thank you in advance. Alvina Link to comment Share on other sites More sharing options...
bernhard Posted June 4, 2018 Share Posted June 4, 2018 hi @asilentwish, not sure, but maybe this module can help you? https://modules.processwire.com/modules/admin-restrict-branch/ 2 Link to comment Share on other sites More sharing options...
adrian Posted June 4, 2018 Share Posted June 4, 2018 Take a look at these: https://gist.github.com/adrianbj/e391e2e343c5620d0720 https://gist.github.com/adrianbj/e391e2e343c5620d0720https://gist.github.com/somatonic/5595081 and this conversation: https://processwire.com/talk/topic/1176-hiding-uneditable-pages-from-users/?do=findComment&comment=84916 4 Link to comment Share on other sites More sharing options...
asilentwish Posted June 5, 2018 Author Share Posted June 5, 2018 Thank you for your replies but that didn't seems to work for me. Here is a screenshot of my problem. I want the submenu (the part in black) to only show the same pages as the listview (left side). When I hover over Structuur I only want to see: Home Vacatures when i hover over Vacatures I only want to see the two pages seen in the left side 1070 1069 Unfortunately I see all pages and can even edit them all. Link to comment Share on other sites More sharing options...
adrian Posted June 5, 2018 Share Posted June 5, 2018 @asilentwish - please take a look at the AdminRestrictBranch module that @bernhard mentions - it takes care of these menus and all sorts of other issues. Obviously it doesn't hide the pages you want, but you'll be able to grab the bits of code you need from that and add it to one of those gists I listed. But please also read thoroughly through that forum thread - there are issues with what you want to do - what if a parent is hidden, but the user needs access to the children? 2 Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now