Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
PW module for hiding pages that don't match the user's name, under a certain parent page - currently hard coded parent name: visitenkarte
* ProcessWire 2.x
* Copyright (C) 2010 by Ryan Cramer
* Licensed under GNU/GPL v2, see LICENSE.TXT
class HideOtherUserPages extends WireData implements Module {
public static function getModuleInfo() {
return array(
'title' => 'HideOtherUserPages',
'author' => 'Adrian Jones',
'version' => 1,
'singular' => true,
'autoload' => true
public function init() {
// only add hook only if the render parameter is set
// (as used by ProcessPageList)
// or if superuser, also exit
if(!isset($_GET['render']) || $this->user->isSuperuser()) return;
$this->addHookAfter('ProcessPageList::execute', $this, 'pageListHiddenPages');
public function pageListHiddenPages(HookEvent $event){
// make sure it's an ajax request
// manipulate the json returned and remove any pages found from array
$json = json_decode($event->return, true);
foreach($json['children'] as $key => $child){
$c = $this->pages->get($child['id']);
if($c->parent->name != 'visitenkarte') continue;
if($c->name != $this->user->name) unset($json['children'][$key]);
$json['children'] = array_values($json['children']);
$event->return = json_encode($json);
Copy link

g-verma commented Nov 18, 2017

you can also edit if($c->createdUser->id != $this->user->id) unset($json['children'][$key]); to
if($c->createdUser->id != $this->user->id) unset($json['children'][$key]);
this will show only those pages which a user has created.

to achieve this i used solution mentioned by adrian on processwire forum, he told me to add new permission 'Page-Edit-Created, and with this you can another module "Hideuneditablepages' with ,'hide other pages' module .
This will show only those pages that a user has created.


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment