Title: wp_ajax_wp_remove_post_lock
Published: April 25, 2014
Last modified: May 20, 2026

---

# wp_ajax_wp_remove_post_lock()

## In this article

 * [Source](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#source)
 * [Hooks](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#hooks)
 * [Related](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#changelog)

[ Back to top](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#wp--skip-link--target)

Handles removing a post lock via AJAX.

## 󠀁[Source](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#source)󠁿

    ```php
    function wp_ajax_wp_remove_post_lock() {
    	if ( empty( $_POST['post_ID'] ) || empty( $_POST['active_post_lock'] ) ) {
    		wp_die( 0 );
    	}

    	$post_id = (int) $_POST['post_ID'];
    	$post    = get_post( $post_id );

    	if ( ! $post ) {
    		wp_die( 0 );
    	}

    	check_ajax_referer( 'update-post_' . $post_id );

    	if ( ! current_user_can( 'edit_post', $post_id ) ) {
    		wp_die( -1 );
    	}

    	$active_lock = array_map( 'absint', explode( ':', $_POST['active_post_lock'] ) );

    	if ( get_current_user_id() !== $active_lock[1] ) {
    		wp_die( 0 );
    	}

    	/**
    	 * Filters the post lock window duration.
    	 *
    	 * @since 3.3.0
    	 *
    	 * @param int $interval The interval in seconds the post lock duration
    	 *                      should last, plus 5 seconds. Default 150.
    	 */
    	$new_lock = ( time() - apply_filters( 'wp_check_post_lock_window', 150 ) + 5 ) . ':' . $active_lock[1];
    	update_post_meta( $post_id, '_edit_lock', $new_lock, implode( ':', $active_lock ) );
    	wp_die( 1 );
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/ajax-actions.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/7.0/src/wp-admin/includes/ajax-actions.php#L2923)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/7.0/src/wp-admin/includes/ajax-actions.php#L2923-L2958)

## 󠀁[Hooks](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#hooks)󠁿

 [apply_filters( ‘wp_check_post_lock_window’, int $interval )](https://developer.wordpress.org/reference/hooks/wp_check_post_lock_window/)

Filters the post lock window duration.

## 󠀁[Related](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#related)󠁿

| Uses | Description | 
| [update_post_meta()](https://developer.wordpress.org/reference/functions/update_post_meta/)`wp-includes/post.php` |

Updates a post meta field based on the given post ID.

  | 
| [current_user_can()](https://developer.wordpress.org/reference/functions/current_user_can/)`wp-includes/capabilities.php` |

Returns whether the current user has the specified capability.

  | 
| [check_ajax_referer()](https://developer.wordpress.org/reference/functions/check_ajax_referer/)`wp-includes/pluggable.php` |

Verifies the Ajax request to prevent processing requests external of the blog.

  | 
| [wp_die()](https://developer.wordpress.org/reference/functions/wp_die/)`wp-includes/functions.php` |

Kills WordPress execution and displays HTML page with an error message.

  | 
| [apply_filters()](https://developer.wordpress.org/reference/functions/apply_filters/)`wp-includes/plugin.php` |

Calls the callback functions that have been added to a filter hook.

  | 
| [get_current_user_id()](https://developer.wordpress.org/reference/functions/get_current_user_id/)`wp-includes/user.php` |

Gets the current user’s ID.

  | 
| [get_post()](https://developer.wordpress.org/reference/functions/get_post/)`wp-includes/post.php` |

Retrieves post data given a post ID or post object.

  |

[Show 5 more](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#)
[Show less](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#)

## 󠀁[Changelog](https://developer.wordpress.org/reference/functions/wp_ajax_wp_remove_post_lock/?output_format=md#changelog)󠁿

| Version | Description | 
| [3.1.0](https://developer.wordpress.org/reference/since/3.1.0/) | Introduced. |

## User Contributed Notes

You must [log in](https://login.wordpress.org/?redirect_to=https%3A%2F%2Fdeveloper.wordpress.org%2Freference%2Ffunctions%2Fwp_ajax_wp_remove_post_lock%2F)
before being able to contribute a note or feedback.