Limit editing of areas simply

Submitted by herent - 3 years ago

Often items like navigation, site wide promos, footer links, etc should be limited in who can edit them. This can be done through permissions in the GUI, but sometimes you want to have more control to keep random users from editing. This works with regular and global areas

// If you only want the superadmin to edit
$a = new GlobalArea("Footer Nav");
$u = new User();
if (!$u->isSuperUser()){
    $a->disableControls();
}
$a->display();

// Limit to one group
$a = new GlobalArea("Footer Nav");
$u = new User();
$g = Group::getByName("Your Group");
if (!$u->inGroup($g)){
    $a->disableControls();
}
$a->display();
Stats Categories Tags
comments powered by Disqus