Reference › Functions wp_set_post_lock ( int | WP_Post $post ): array | false
Since 2.5.0
Source wp-admin/includes/post.php:1760Parameters Return Uses Used by Source History Marks the post as currently being edited by the current user.
Parameters
$postint | WP_PostID or object of the post being edited. Return array | falseArray of the lock time and user ID. False if the post does not exist, or there is no current user. Used by · 3 edit_post() Updates an existing post with values provided in `$_POST`. wp_refresh_post_lock() Checks lock status on the New/Edit Post screen and refresh the lock. wp_write_post() Creates a new post from the "Write Post" form using `$_POST` information. Source View on Trac ↗ View on GitHub ↗
1760 function wp_set_post_lock ( $post ) { 1761 $post = get_post ( $post ) ; 1762 1763 if ( ! $post ) { 1764 return false ; 1765 } 1766 1767 $user_id = get_current_user_id ( ) ; 1768 1769 if ( 0 === $user_id ) { 1770 return false ; 1771 } 1772 1773 $now = time ( ) ; 1774 $lock = "$now :$user_id " ; 1775 1776 update_post_meta ( $post -> ID , '_edit_lock' , $lock ) ; 1777 1778 return array ( $now , $user_id ) ; 1779 } History Introduced in 2.5.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 7.0.4 tag, from src/wp-admin/includes/post.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.