wp_set_post_lock()WP 2.5.0

Marks the post as currently being edited by the current user.

Хуков нет.

Возвращает

Массив|false. Array of the lock time and user ID. False if the post does not exist, or there is no current user.

Использование

wp_set_post_lock( $post );
$post(int|WP_Post) (обязательный)
ID or object of the post being edited.

Список изменений

С версии 2.5.0 Введена.

Код wp_set_post_lock() WP 6.5.2

function wp_set_post_lock( $post ) {
	$post = get_post( $post );

	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 );
}