WordPress开发者和主题制作者的搜索引擎



wp_set_post_lock ›

Since2.5.0
已弃用n/a
wp_set_post_lock ( $post_id )
参数:
  • (int) $post_id ID of the post being edited.
    Required: Yes
返回:
  • (array|false) Array of the lock time and user ID. False if the post does not exist, or there is no current user.
定义在:
文档:

Mark the post as currently being edited by the current user



源码

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