As you already know, authors and contributors are limited to editing their own work.
But editors and administrators have more sweeping powers; they can dip into any
page or post and make changes.
This setup creates the possibility of conflicts. An editor could start editing a post
that a contributor is still writing. Or two editors could attempt to revise the same
work at the same time. WordPress doesn’t have any post collaboration features—
instead, only one person at a time can revise a post and save changes. To prevent
one person’s edits from wiping out another person’s work, WordPress uses a simple
post locking system.
Here’s an example of how it works. If Diane starts editing a post, WordPress takes
note. Every 15 seconds, it sends a message from Diane’s browser to the server,
which essentially says, “I’m still working!” (This message is part of an internal system
called the Heartbeat API.) If Diane stops editing—say, she saves her work and
navigates to another page, or she just closes the browser window without a second
thought—the messages stop and WordPress realizes (within 15 seconds or so) that
Diane has stopped working.
When you look at the posts on the All Posts page, WordPress shows you which ones
are currently being edited.
Life gets more interesting when someone else joins the editing party. For example,
consider what happens if Lisa attempts to edit the post Diane is working on. Word-
Press notices the conflict the moment Lisa picks up the post, and shows a warning
message (Figure 11-10, top). Now it’s up to Lisa to decide whether she wants to wait
for Diane to finish (by clicking “Go back”) or push her out of the way and take over
(by clicking “Take over”;
NOTE When it comes to taking over a post, everyone is created equal. For example, if Lisa wants to take
over the post that Diane is editing, it doesn’t matter if Diane is an administrator or a lowly contributor. Nor does
it matter who created the post. As long as Lisa is allowed to edit the post, she’ll be able to wrest control from
anyone who’s currently working on it.
Diane has no chance to stop Lisa’s post takeover. Once it happens, her editing session
ends. All she can do is click “All Posts” to return to the post list. However, once
Diane is back at the post list, nothing stops her from editing the same post again.
If she does, she’ll see the same warning message that Lisa saw, informing her that
someone else is working on the post. If she forges ahead, Lisa will be kicked out of
her editing session.
Of course, the point of the post locking system isn’t for editors and authors to become
locked in a series of dueling edits. Instead, it’s for times when someone still
has a post open but probably isn’t editing it anymore. For example, if Diane starts
revising a post but walks away from her computer for lunch, Lisa can still get some
work done by assuming control of Diane’s work in progress.