bbp_set_post_lock( int $post_id )

Mark the post as currently being edited by the current user


Description Description


Parameters Parameters

$post_id

(Required) ID of the post to being edited


Top ↑

Return Return

(bool|array) Returns false if the post doesn't exist of there is no current user, or an array of the lock time and the user ID.


Top ↑

Source Source

File: includes/common/locks.php

function bbp_set_post_lock( $post_id = 0 ) {

	// Bail if no post
	if ( !$post = get_post( $post_id ) ) {
		return false;
	}

	// Bail if no user
	if ( 0 == ( $user_id = get_current_user_id() ) ) {
		return false;
	}

	// Get time & lock value
	$now  = time();
	$lock = "{$now}:{$user_id}";

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

	return array( $now, $user_id );
}

Top ↑

Changelog Changelog

Changelog
Version Description
2.6.0 Introduced.

Top ↑

User Contributed Notes User Contributed Notes

You must log in before being able to contribute a note or feedback.