<p>Seems like you'd just need to write a <a href="http://pluginfactory.io" rel="nofollow">plugin</a> that <a href="https://craftcms.com/docs/plugins/hooks-and-events" rel="nofollow">listened</a> to the <a href="https://craftcms.com/docs/plugins/events-reference#entries-onBeforeSaveEntry" rel="nofollow">onBeforeSaveEntry</a> event.</p>

<p>That plugin would check if the entry author is in the user group you're interested in, and if it's a new entry just let it save.</p>

<p>If it's an existing entry, check the dateCreated date against your window and see if it's still valid.  If it's outside of your window you can set <a href="https://craftcms.com/classreference/etc/events/Event#performAction-detail" rel="nofollow">performAction</a> to <code>false</code> so the entry won't save and set a flash message indicating they're outside the window.</p>

CC BY-SA 3.0
2016-09-18T07:44:45.093Z
That gets me moving in the right direction though I was hoping to be able to notify the user before they hit save. If they did a lengthly edit and tried to save it could be very frustrating for them! This solution lets me tick the box on the spec (thank you) but it would be nice to be able to polish the UX on this one. Any ideas?
Leonard
CC BY-SA 3.0
2016-09-16T23:36:24.810Z
2016-09-16T23:36:24.810Z
Brad Bell
<p>I have a group of users who are allowed to create entries and edit them but I want to put a window on how much time they have in which they can edit it. For example, after initial submission they would only have two weeks to edit the entry before only an admin can make changes to that entry.</p>

<p>I understand how to run the logic to check the user groups and calculate cut-off dates but I have no idea where I need to hook in to be able to do this.</p>

<p>Is there anywhere I can hook in to run this logic? If so, where is this?</p>

<p>Any guidance would be really appreciated!</p>

<plugin-development><entries><admin><events><hook>
Close entry editing after set time (for certain a user group)
# Close entry editing after set time (for certain a user group)

(Asked by: username_0 on 2016-09-16)

I have a group of users who are allowed to create entries and edit them but I want to put a window on how much time they have in which they can edit it. For example, after initial submission they would only have two weeks to edit the entry before only an admin can make changes to that entry.

I understand how to run the logic to check the user groups and calculate cut-off dates but I have no idea where I need to hook in to be able to do this.

Is there anywhere I can hook in to run this logic? If so, where is this?

Any guidance would be really appreciated!

**Tags:** plugin-development, entries, admin, events, hook

---

## 1 answers

### Answer by username_1 on 2016-09-16. Score: 2

Seems like you'd just need to write a [plugin](http://pluginfactory.io) that [listened](https://craftcms.com/docs/plugins/hooks-and-events) to the [onBeforeSaveEntry](https://craftcms.com/docs/plugins/events-reference#entries-onBeforeSaveEntry) event.

That plugin would check if the entry author is in the user group you're interested in, and if it's a new entry just let it save.

If it's an existing entry, check the dateCreated date against your window and see if it's still valid. If it's outside of your window you can set [performAction](https://craftcms.com/classreference/etc/events/Event#performAction-detail) to `false` so the entry won't save and set a flash message indicating they're outside the window.

> **Comments:**
> **username_0**: That gets me moving in the right direction though I was hoping to be able to notify the user before they hit save. If they did a lengthly edit and tried to save it could be very frustrating for them! This solution lets me tick the box on the spec (thank you) but it would be nice to be able to polish the UX on this one. Any ideas?  

---

