Jump to content

prevent settings tab in page edit


Spica
 Share

Recommended Posts

Hi Spica!

Create a new permission called "page-edit-show-settings-tab" and adjust the roles to fit your needs.

In /site/templates/admin.php add the following before the line: require($config->paths->adminTemplates . 'controller.php');

function hideSettingsTab(HookEvent $event) {
	// Get the page being edited
	$page = $event->object->getPage();

	if (!wire('user')->hasPermission('page-edit-show-settings-tab', $page)) {
		$page->template->set('noSettings', 1);
	}
}

$wire->addHookBefore('ProcessPageEdit::buildForm', null, 'hideSettingsTab');

After a quick test, this seems to work fine on my setup. 

  • Like 12
Link to comment
Share on other sites

Nice solution.

Ended up with this as a autoload module

<?php

class Helloworld extends WireData implements Module {

    public static function getModuleInfo() {
        return array(
            'title' => 'Hello World',
            'version' => 1,
            'singular' => true,
            'autoload' => true,
			'summary' => 'Anpassungen',
			'icon' => 'smile-o', 
            );
    }

    public function init() {
        $this->addHookBefore('ProcessPageEdit::buildForm', $this, 'hideSettingsTab');
    }


	function hideSettingsTab(HookEvent $event) {
		if($this->user->hasRole("presenter")) {
			$page = $event->object->getPage();
			$page->template->set('noSettings', 1);
		}
	}

}
  • Like 6
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...