wp_set_post_lock

Advertisement

Summery Summery

Mark the post as currently being edited by the current user

Syntax Syntax

wp_set_post_lock( int $post_id )

Parameters Parameters

$post_id

(Required) ID of the post being edited.

Return Return

(array|false) Array of the lock time and user ID. False if the post does not exist, or there is no current user.

Source Source

File: wp-admin/includes/post.php

function wp_set_post_lock( $post_id ) {
	$post = get_post( $post_id );
	if ( ! $post ) {
		return false;
	}

	$user_id = get_current_user_id();
	if ( 0 == $user_id ) {
		return false;
	}

	$now  = time();
	$lock = "$now:$user_id";

	update_post_meta( $post->ID, '_edit_lock', $lock );

	return array( $now, $user_id );
}

Advertisement

Changelog Changelog

Changelog
Version Description
2.5.0 Introduced.

Advertisement

Leave a Reply