Revoke group administrator permission to edit any group post

Last updated on
30 April 2025

Tagging myself as 'insecure code' because I am not 100% sure of all possible outcomes, if someone more familiar with drupal internals finds that this code is a OK, please remove this status.

OG lets group administrators to edit any node posted in group. For those, who think such permission is too much and node can be edited only by author, god (user 1) or someone with permission to 'administer nodes' and group admin can only view any node in his group, here is my recipe.

In your custom module create this function...

function MODULENAME_og_access_grants_alter($grants, $node) {
	foreach ($grants as $key => $grant) {
		if($grant['realm'] == 'og_admin') {
			$grants[$key]['grant_view'] = 1;
			$grants[$key]['grant_update'] = NULL;
			$grants[$key]['grant_delete'] = NULL;
		}
	}
	return $grants;
}

Help improve this page

Page status: Not set

You can: