Open armandostyl opened 2 months ago
Checking if a user is in a group is a little more complex from what I can see in the documentation. To achieve this you will need to modify the includePageTools
method within the mikio.php
file (note this will be overwritten in updates so not the best approach).
public function includePageTools(bool $print = true, bool $includeId = false): string
{
global $USERINFO;
// START CUSTOM CODE
// determine if the current user is in the moderators group and
// set $showEditPage
global $_SESSION;
$showEditPage = false;
if (isset($_SESSION[DOKU_COOKIE]['auth']['info']['grps']) &&
is_array($_SESSION[DOKU_COOKIE]['auth']['info']['grps']) &&
in_array('moderators', $_SESSION[DOKU_COOKIE]['auth']['info']['grps'], true)) {
$showEditPage = true;
}
// END CUSTOM CODE
// ......
$classes = array_unique($classes);
$title = isset($attr['title']) && $attr['title'] !== 0 ? $attr['title'] : $item->getTitle();
// START CUSTOM CODE
// if we are working with the page edit button, check if we should
// show it to the current user
if(!$showEditPage && in_array('edit', $classes)) {
continue;
}
// END CUSTOM CODE
// ......
Is there a better way to implement this though?
No, not without building it into the template itself as a configuration option
Hi,
If I were to hide the edit page button from all users except for a certain group (e.g. "moderators"), how would I go about editing the template? I tried adding a conditional
$_SERVER['REMOTE_USER'] == "@moderators"
atbut it didn't work.