Reference › Functions wp_set_post_lock ( int | WP_Post $post ): array | false
Since 2.5.0
Source wp-admin/includes/post.php:1746Parameters 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 ↗
1746 function wp_set_post_lock ( $post ) { 1747 $post = get_post ( $post ) ; 1748 1749 if ( ! $post ) { 1750 return false ; 1751 } 1752 1753 $user_id = get_current_user_id ( ) ; 1754 1755 if ( 0 === $user_id ) { 1756 return false ; 1757 } 1758 1759 $now = time ( ) ; 1760 $lock = "$now :$user_id " ; 1761 1762 update_post_meta ( $post -> ID , '_edit_lock' , $lock ) ; 1763 1764 return array ( $now , $user_id ) ; 1765 } 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 6.7.7 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.