theo Posted March 10, 2018 Share Posted March 10, 2018 Hello I think my "editors" should not see the 404 page in the list (backend). I guess this page should not be deleted for technical reasons. Is this right? If so, what is the best way to hide it? I have written a little module (code below) and this seems to do what I want. But is it a good way? Is there anything I have overlooked? Or is this overkill and there is a much simpler way? Thank you. <?php namespace ProcessWire; class HideAdminPages extends WireData implements Module { public static function getModuleInfo() { return array( 'title' => 'HideAdminPages', 'author' => 'Theo', 'version' => 1, 'singular' => true, 'autoload' => true ); } public function init() { if (!$this->user->hasRole('editorrole')) return; //hide for editorrole only $this->addHookAfter('ProcessPageList::find', $this, 'pageListFind'); } public function pageListFind(HookEvent $event){ $pages = $event->return; if($this->config->ajax){ foreach($pages as $p) { if($p->id == 27) $pages->remove($p); //27 is the 404 Page } $event->return = $pages; } } } Link to comment Share on other sites More sharing options...
kongondo Posted March 10, 2018 Share Posted March 10, 2018 5 hours ago, theo said: I guess this page should not be deleted for technical reasons. Is this right? Nope. You can delete it if you want. In that case, let PW know what to use for 404 config (see below) 5 hours ago, theo said: Or is this overkill... Yes. Quite the overkill . 5 hours ago, theo said: a much simpler way? just move page with ID 27 under /admin/ (i.e., re-parent it). Editors will not be able to see it. OR Create a new 404 page under /admin/ (and delete page with ID 27 or reuse it for whatever). Editors will not be able to see it. Add this to /site/config.php $config->http404PageID = 1234;// ID of your new hidden 404 page. That's all there is to it. 4 Link to comment Share on other sites More sharing options...
theo Posted March 10, 2018 Author Share Posted March 10, 2018 @kongondo Perfect, thank you! Link to comment Share on other sites More sharing options...
theo Posted March 1, 2019 Author Share Posted March 1, 2019 For the record: According to Ryan, it is not good to move the 404 Page under "admin". https://github.com/processwire/processwire-issues/issues/817 1 Link to comment Share on other sites More sharing options...
dragan Posted March 1, 2019 Share Posted March 1, 2019 You could also do it with simple CSS: body:not(.role-superuser) .PageListID27 { display: none; } 2 Link to comment Share on other sites More sharing options...
szabesz Posted March 1, 2019 Share Posted March 1, 2019 (edited) 12 hours ago, dragan said: .role-superuser In his other post I also recommended this but .role-superuser seems to be added by AdminOnSteroids only... Edited March 2, 2019 by szabesz typo 1 Link to comment Share on other sites More sharing options...
dragan Posted March 1, 2019 Share Posted March 1, 2019 oops, my bad. Didn't realize that, sorry. 2 Link to comment Share on other sites More sharing options...
millipedia Posted June 21, 2022 Share Posted June 21, 2022 Just keeping this thread up to date in case anyone is searching for how to do this still (and I know I'll forget so it will probably be me), the ProcessPageList module now has a configuration option to let you hide pages from users: 2 1 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