<p>Inspired in part by Mats' detailed answer, I've written a plugin that does just this: <a href="https://straightupcraft.com/craft-plugins/mn-snitch" rel="nofollow">MN Snitch</a></p>

<p>Enjoy!</p>

CC BY-SA 3.0
2016-09-16T13:14:14.150Z
Great stuff, thanks Marion, will give this a go!
André Goldstein
CC BY-SA 3.0
2016-09-16T06:03:03.283Z
2016-09-16T06:03:03.283Z
Marion Newlevant
<p>It's definitely a feature Craft is missing, and I've had requests from several clients who are frustrated about it (not super frustrated, fortunately, because everything else in Craft is so much better than whatever else they were using before) :D</p>

<p>Implemented as a plugin, in my opinion there are two primary problems to solve – the first is how to "store" the "being edited" state for an entry being edited (and obviously, clearing that state once the entry is no longer being edited), and the second is how to communicate that state to any other users attempting to edit the same entry.</p>

<p>The first problem could easily be solved by using AJAX in order to save the entry ID to a custom database row, keeping track of entries being edited. The real problem is how to ascertain that an entry is being edited, or even that a user is in fact interacting with an entry editing form (an issue <a href="http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/10689150-entry-onopen-hook" rel="nofollow">the second feature request Brad links to</a> in his answer deals with).</p>

<p>The second problem could probably be solved by either using basic AJAX polling, where a script checks with the server on pageload, and then every X seconds, if the "being edited" state of the current entry has changed; displaying the appropriate message to the user once it does (Craft uses this approach for login timeouts). Websockets would of course be an even better approach, but is a bit more troublesome to set up.</p>

<p>I've actually done some work on a plugin just like this myself (unfortunately, its nowhere close to being finished yet, and might never be!), which uses <a href="https://pusher.com/" rel="nofollow">Pusher</a> (essentially websockets as a service) for problem #2. For problem #1, I've previously "solved" this in other plugins like <a href="https://github.com/mmikkel/Reasons-Craft" rel="nofollow">Reasons</a> by using jQuery to parse the Control Panel HTML, looking for the appropriate form input fields (for instance, the entry editing form would have a hidden <code>action</code> input with the value <code>entries/saveEntry</code>, as well as an input named <code>entryId</code>), in order to identify the current page as an entry editing form. Basically, hacks that could break at any time, e.g. if P&amp;T redesigns the Control Panel.</p>

<p>Beyond this, there are a plethora of other issues to solve. For instance, entries in Craft can be edited in several different ways, so the plugin probably needs to handle element editor modals and Live Preview as well. Also, making sure that an entry is "unlocked" is not as easy as it sounds – a JavaScript "unload" handler would probably work in most cases, but is fickle, in my experience, so there would probably need to be some sort of timestamping feature built in as well, and probably a task to clean up old/stale "being edited" rows from the database.</p>

<p>Due to the potential complexity of the feature, I really hope P&amp;T builds it into core some day. If not, I'm sure a plugin will pop up sooner or later (mine or someone else's).</p>

CC BY-SA 3.0
2016-05-07T17:18:51.810Z
Many thanks for such a detailed write up! Out of interest, here is the corresponding module from PW (by Soma). 

https://github.com/somatonic/PageEditSoftLock

It's 3 years old and pretty sure it's not covering all the bases you mentioned. Just a warning on a traditional edit page.
André Goldstein
CC BY-SA 3.0
2016-05-07T17:54:29.567Z
@AndréGoldstein Thanks, that's interesting. It's basically working exactly as I described above; first by keeping a record of entries being edited in the database, and then a combination of timestamps and AJAX polling to communicate messages about the entries' status to the end user.
Mats Mikkel Rummelhoff
CC BY-SA 3.0
2016-05-07T13:55:26.440Z
2016-05-07T14:00:43.503Z
2016-05-07T14:00:43.503Z
Mats Mikkel Rummelhoff
<p>I can't think of an easy way for a plugin to currently do this, but you should consider voting for these feature requests that would enable this scenario:</p>

<p><a href="http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/9009169-add-an-alert-or-warning-when-multiple-authors-are" rel="nofollow">http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/9009169-add-an-alert-or-warning-when-multiple-authors-are</a></p>

<p><a href="http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/10689150-entry-onopen-hook" rel="nofollow">http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/10689150-entry-onopen-hook</a></p>

CC BY-SA 3.0
2016-05-06T16:47:48.963Z
2016-05-06T16:47:48.963Z
Brad Bell
<p>In a previous CMS we used (Processwire), one of the authors created a very useful plugin that would warn a user on an edit page that the page was currently being edited by another user.</p>

<p>I'm thinking this would be a useful addition, unless Craft's use of automatic versioning would somewhat rule out the risk of overwriting someone else's work?</p>

<p>Has anyone had any similar thoughts on the issue?</p>

<p>Thanks.</p>

<plugin-development><admin>
Would it be possible to create a plugin to warn a user if a page is being edited
# Would it be possible to create a plugin to warn a user if a page is being edited

(Asked by: username_0 on 2016-05-06)

In a previous CMS we used (Processwire), one of the authors created a very useful plugin that would warn a user on an edit page that the page was currently being edited by another user.

I'm thinking this would be a useful addition, unless Craft's use of automatic versioning would somewhat rule out the risk of overwriting someone else's work?

Has anyone had any similar thoughts on the issue?

Thanks.

**Tags:** plugin-development, admin

---

## 3 answers

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

Inspired in part by Mats' detailed answer, I've written a plugin that does just this: [MN Snitch](https://straightupcraft.com/craft-plugins/mn-snitch)

Enjoy!

> **Comments:**
> **username_0**: Great stuff, thanks Marion, will give this a go!  

---

### Answer by username_2 on 2016-05-07. Score: 3

It's definitely a feature Craft is missing, and I've had requests from several clients who are frustrated about it (not super frustrated, fortunately, because everything else in Craft is so much better than whatever else they were using before) :D

Implemented as a plugin, in my opinion there are two primary problems to solve – the first is how to "store" the "being edited" state for an entry being edited (and obviously, clearing that state once the entry is no longer being edited), and the second is how to communicate that state to any other users attempting to edit the same entry.

The first problem could easily be solved by using AJAX in order to save the entry ID to a custom database row, keeping track of entries being edited. The real problem is how to ascertain that an entry is being edited, or even that a user is in fact interacting with an entry editing form (an issue [the second feature request Brad links to](http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/10689150-entry-onopen-hook) in his answer deals with).

The second problem could probably be solved by either using basic AJAX polling, where a script checks with the server on pageload, and then every X seconds, if the "being edited" state of the current entry has changed; displaying the appropriate message to the user once it does (Craft uses this approach for login timeouts). Websockets would of course be an even better approach, but is a bit more troublesome to set up.

I've actually done some work on a plugin just like this myself (unfortunately, its nowhere close to being finished yet, and might never be!), which uses [Pusher](https://pusher.com/) (essentially websockets as a service) for problem #2. For problem #1, I've previously "solved" this in other plugins like [Reasons](https://github.com/mmikkel/Reasons-Craft) by using jQuery to parse the Control Panel HTML, looking for the appropriate form input fields (for instance, the entry editing form would have a hidden `action` input with the value `entries/saveEntry`, as well as an input named `entryId`), in order to identify the current page as an entry editing form. Basically, hacks that could break at any time, e.g. if P&T redesigns the Control Panel.

Beyond this, there are a plethora of other issues to solve. For instance, entries in Craft can be edited in several different ways, so the plugin probably needs to handle element editor modals and Live Preview as well. Also, making sure that an entry is "unlocked" is not as easy as it sounds – a JavaScript "unload" handler would probably work in most cases, but is fickle, in my experience, so there would probably need to be some sort of timestamping feature built in as well, and probably a task to clean up old/stale "being edited" rows from the database.

Due to the potential complexity of the feature, I really hope P&T builds it into core some day. If not, I'm sure a plugin will pop up sooner or later (mine or someone else's).

> **Comments:**
> **username_0**: Many thanks for such a detailed write up! Out of interest, here is the corresponding module from PW (by Soma).   https://github.com/somatonic/PageEditSoftLock  It's 3 years old and pretty sure it's not covering all the bases you mentioned. Just a warning on a traditional edit page.  
> **username_2**: @AndréGoldstein Thanks, that's interesting. It's basically working exactly as I described above; first by keeping a record of entries being edited in the database, and then a combination of timestamps and AJAX polling to communicate messages about the entries' status to the end user.  

---

### Answer by username_3 on 2016-05-06. Score: 2

I can't think of an easy way for a plugin to currently do this, but you should consider voting for these feature requests that would enable this scenario:

<http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/9009169-add-an-alert-or-warning-when-multiple-authors-are>

<http://feedback.craftcms.com/forums/285221-feature-requests/suggestions/10689150-entry-onopen-hook>


---

