Skip to content

Instantly share code, notes, and snippets.

@adamkiss
Created April 24, 2012 22:19
Show Gist options
  • Save adamkiss/2484276 to your computer and use it in GitHub Desktop.
Save adamkiss/2484276 to your computer and use it in GitHub Desktop.
ProcessWire user access 909 (uber-advanced)
<?php
//This just blew my mind
//
//User has field 'userPages'[Pagefield type], where administrator added parts of whole tree avail. to user.
//This checks whether current page (wrapped in object) or any of its parents was added to this 'userPages'
//(thus current page or anything higher in the hierarchy gives user the access)
//wow.
$access =
count(
Wire::getFuel('user')->userPages->find(
'id='.$this->page->parents()
->append($this->page)
)
) > 0;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment