Jump to content

Making unpublished changes to pages that require approval?


mpdude
 Share

Recommended Posts

Hey there ??,

I am evaluating ProcessWire for a new project, so this might be an easy question for somebody with more experience...

Is it possible to configure permissions in a way that certain users may make changes to existing pages and preview those, but the changes will not yet be published (is that the right term?) and visible to anyone else. Only when another user with more permisssions (say, a reviewer) approves a certain change it will become visible for all website visitors?

Thanks!

Link to comment
Share on other sites

@mpdude try this hook

– Create a role for user, who should not be able to publish pages
– Put this in ready.php file in the site directory

$wire->addHookBefore('Pages::save', function(HookEvent $event) {
	$page = $event->arguments(0);
	$userRole = wire('user')->role;
	$page->of(false);
	if($userRole == "your_user_role_which_can_not_publish_pages") {
		$page->status('unpublished');
	}		
});

 

 

  • Like 1
Link to comment
Share on other sites

@mpdude Using the hook like @ngrmm posted above you can fulfil this requirement:

"certain users may make changes to existing pages and preview those, but the changes will not yet be published (is that the right term?) and visible to anyone else. Only when another user with more permissions (say, a reviewer) approves a certain change it will become visible for all website visitors?"

And you could use Robin's module to also let clients review a page before it is published by the reviewer.

  • Like 1
Link to comment
Share on other sites

@ngrmm what you say is correct and it's very easy to PREVENT publishing of unpublished pages. But if I'm reading correctly @mpdude requested a process where an EXISTING (aka published) page can be edited by a user, but the CHANGE to that page is not published until a more privileged user approves that change, but with the original page staying unchanged and published throughout the whole change request process.

I don't have experience with the ProDrafts module but it sounds like a good candidate ? Alternatively you could implement a custom logic like this:

  • user clicks on "change request".
  • you use the PW api to clone that page (that's really easy) and you save it under eg /drafts.
  • you save a reference to the original page, eg via $newpage->meta('originalpage', $oldpage->id)
  • you send an email to an admin that a new change request was created (easy using WireMail).
  • you add a button "approve" to that page. once that button is clicked, you loop over all fields of that page and save that content to the original page (using the page meta reference).
  • after that you can delete the draft page and you have all the changes on your original page.

That way you can quite easily build very custom workflows that exactly fit your clients needs.

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