How to check for Locks of current user

Hi!

I recently realised that my many-to-many plugin has a bug: if you have unsaved edits of a page in a tab (so its locked) and add a many-to-many relation via the plugin, then come back and save your changes, the many-to-many relation is deleted because you override the page with the locked state from your tab. The easy solution for this would be to check in the plugin if the page which should be updated is locked. The problem here is: the plugin uses the same user as the one who edits, so the isLocked function always returns false. (If I get it right, it only returns true if another user locked the page). Is there a way to check if the current user locked a page?

Thanks!

You could create a custom page method that sligthly changes the underlying logic of the isLocked() method (kirby/ContentLock.php at 021561f7444896fc9917eccb52768a6e715e9a74 · getkirby/kirby · GitHub)

1 Like

Thats a very good idea, thanks a lot as always!!