valan Posted December 5, 2015 Share Posted December 5, 2015 How to assign a permission (to the role) that allows only published pages (of some template) editing AND does not allow editing of unpublished pages? E.g. I want to disable pub/unpub action button both in tree and in Listers for some role/template, but leave editing. Link to comment Share on other sites More sharing options...
kixe Posted December 6, 2015 Share Posted December 6, 2015 Unfortunately this is not possible with built in permissions. Only the other way round is possible. You can add some permissions manually which are known by PW. page-publish: Publish/unpublish pages or edit already published pages. When installed, editable() returns false, when it would otherwise return true, on published pages, if user doesn't have page-publish permission in their roles. page-hide: Hide/unhide pages page-edit-created: Edit only pages user has created page-rename: Change the name of published pages they are allowed to edit user-admin-all: Administer users in any role (except superuser) Have a deeper look here:https://processwire.com/api/user-access/permissions/#optional-core-permissions 2 Link to comment Share on other sites More sharing options...
adrian Posted December 6, 2015 Share Posted December 6, 2015 I think you should be able to achieve what you want by hooking into Page::editable I think this should do what you are looking for - just edit the template you want to match. Keep in mind that in this form it will even prevent superusers from editing the page, so you might want to check that before adding the hook $this->addHookAfter('Page::editable', null, 'hookPageEditable'); function hookPageEditable($event) { $p = $event->object; // in case there is already a defined exclusion for this user's role for this page if(!$event->return) return; if($p->template->name == "basic-page" && $p->hasStatus(Page::statusUnpublished)) { $event->return = false; } else { $event->return = true; } } 2 Link to comment Share on other sites More sharing options...
adrian Posted December 6, 2015 Share Posted December 6, 2015 Actually I just realized I might have been a bit confused by what you want - I thought what I wrote answered the first sentence in your question, but the second sentence suggests you want to hide the pub/unpub action buttons, in which case try this in your ready.php $this->addHookAfter('ProcessPageListActions::getExtraActions', null, 'hookGetExtraActions'); function hookGetExtraActions($event) { $page = $event->arguments[0]; $extras = $event->return; if($page->template->name == "basic-page" && $page->hasStatus(Page::statusUnpublished)) { unset($extras["pub"]); } $event->return = $extras; } You can remove the page status check for unpublished and also add: unset($extras["unpub"]); if you want to remove that as well. 2 Link to comment Share on other sites More sharing options...
valan Posted December 6, 2015 Author Share Posted December 6, 2015 @adrian thanks! I've found one more solution that addresses own Q and does not require code. It is as simple as (1) setting "Don't allow unpublished pages" in template advanced settings and (2) adding role-publish permission in template access tab. As a result, there are no unpublished pages => no "pub/unpub" buttons while user in role is allowed to edit published pages.) 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now