Jump to content

Is there a way to hide the Settings tab by role?


modifiedcontent
 Share

Recommended Posts

Is there a way to hide the Settings tab in admin/page/edit by role?

I am fine-tuning my members view. Processwire is such a nice system, so much access control by fields and templates etc. But I can't figure out how to hide the Settings tab. I want members to be able to edit their profile page, but not change the "slug", template, publication status, etc. 

Using access/roles/edit I think I can block access to 'change template' with 'revoke from: template', but the template still shows up in Settings, not editable with or without revoke - I made that unchangeable somewhere else. The slug name is editable and really shouldn't be for members.

I see there is a module for this - haven't tested yet... Is that still the way to go or is there a build-in solution?

Link to comment
Share on other sites

  • modifiedcontent changed the title to Is there a way to hide the Settings tab by role?

Found a solution based on @Fokke's solution from 2015. Adding the following in admin.php, before the line `require($config->paths->adminTemplates . 'controller.php');` gets me the behavior I needed; Settings only shows up for the SuperUser:

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

	if ( !wire('user')->isSuperuser() ) {
		$page->template->set('noSettings', 1);
	}
}

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

This solution is easy to adapt for whatever your needs are. 

  • Like 3
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...