Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress

Liam Maclachlan
Liam Maclachlan
22,805 Points

How do you lock a page in wordpress if another user is currently on it?

The plugin I am working on would be incredibly lacking if users could edit the same info at the same time. Is there a WP function to detect if another user is accessing the page?

Closest thing I can see to this would be the Post Locking

1 Answer

Liam Maclachlan
Liam Maclachlan
22,805 Points

The way I think I am going to have to do this is by, as they have with post locking, using AJAX requests to send a signal to the server that changes a flag on the database. If the request is unheard of for a few minutes, or the user saves the page, the page unlocks for all users.

As a fall back, other user can request to kick people from pages, where a notification will pop up that needs to be denied within x amount of time, or they are kicked.

Liam Maclachlan
Liam Maclachlan
22,805 Points

Check out this link here for more info on their Heartbeat API