Title: wp_refresh_post_lock
Published: April 25, 2014
Last modified: February 24, 2026

---

# wp_refresh_post_lock( array $response, array $data, string $screen_id ): array

## In this article

 * [Parameters](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#parameters)
 * [Return](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#return)
 * [Source](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#source)
 * [Related](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#related)
 * [Changelog](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#changelog)

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

Checks lock status on the New/Edit Post screen and refresh the lock.

## 󠀁[Parameters](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#parameters)󠁿

 `$response`arrayrequired

The Heartbeat response.

`$data`arrayrequired

The $_POST data sent.

`$screen_id`stringrequired

The screen ID.

## 󠀁[Return](https://developer.wordpress.org/reference/functions/wp_refresh_post_lock/?output_format=md#return)󠁿

 array The Heartbeat response.

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

    ```php
    function wp_refresh_post_lock( $response, $data, $screen_id ) {
    	if ( array_key_exists( 'wp-refresh-post-lock', $data ) ) {
    		$received = $data['wp-refresh-post-lock'];
    		$send     = array();

    		$post_id = absint( $received['post_id'] );

    		if ( ! $post_id ) {
    			return $response;
    		}

    		if ( ! current_user_can( 'edit_post', $post_id ) ) {
    			return $response;
    		}

    		$user_id = wp_check_post_lock( $post_id );
    		$user    = get_userdata( $user_id );

    		if ( $user ) {
    			$error = array(
    				'name' => $user->display_name,
    				/* translators: %s: User's display name. */
    				'text' => sprintf( __( '%s has taken over and is currently editing.' ), $user->display_name ),
    			);

    			if ( get_option( 'show_avatars' ) ) {
    				$error['avatar_src']    = get_avatar_url( $user->ID, array( 'size' => 64 ) );
    				$error['avatar_src_2x'] = get_avatar_url( $user->ID, array( 'size' => 128 ) );
    			}

    			$send['lock_error'] = $error;
    		} else {
    			$new_lock = wp_set_post_lock( $post_id );

    			if ( $new_lock ) {
    				$send['new_lock'] = implode( ':', $new_lock );
    			}
    		}

    		$response['wp-refresh-post-lock'] = $send;
    	}

    	return $response;
    }
    ```

[View all references](https://developer.wordpress.org/reference/files/wp-admin/includes/misc.php/)
[View on Trac](https://core.trac.wordpress.org/browser/tags/6.9.4/src/wp-admin/includes/misc.php#L1183)
[View on GitHub](https://github.com/WordPress/wordpress-develop/blob/6.9.4/src/wp-admin/includes/misc.php#L1183-L1226)

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

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

Retrieves the avatar URL.

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

Determines whether the post is currently being edited by another user.

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

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

  | 
| [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.

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

Retrieves the translation of $text.

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

Retrieves user info by user ID.

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

Converts a value to non-negative integer.

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

Retrieves an option value based on an option name.

  |

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

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

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

## User Contributed Notes

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