Last active
May 30, 2016 07:15
-
-
Save arjenblokzijl/5ee880474f59391a640f975d8fa300b4 to your computer and use it in GitHub Desktop.
ProcessWire duplicate role with permissions and field access
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php namespace ProcessWire; | |
include('index.php'); | |
$contractingRole = wire('roles')->get('contracting-user'); | |
$managerRole = wire('roles')->get('manager'); | |
$managerRole->of(false); | |
$managerRole->permissions = $contractingRole->permissions; | |
$managerRole->save(); | |
foreach (wire('fields') as $f) { | |
if (in_array($contractingRole->id, $f->viewRoles)) { | |
$array = $f->viewRoles; | |
$array[] = $managerRole->id; | |
$f->viewRoles = $array; | |
$f->save(); | |
} | |
echo $f->name; | |
echo "<hr>"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment