---
url: /hooks/filters/wpce-edit-screen-error.md
description: >-
  Provide a custom error message instead of the WPCE editor when edit-screen
  validation fails.
---

# `wpce_edit_screen_error`&#x20;

Filters the error message in the post edit screen.

If an error message is returned from this filter, the WPCE editor will not be shown and the error message will be displayed instead.

## Parameters

1. `?string $edit_screen_error`

   The error message to show. `null` if no error occured.

2. `WP_Post $post`

   The post that should be edited.

## Example

```php
add_filter('wpce_edit_screen_error', function (?string $edit_screen_error, WP_Post $post) {
	if ($post->post_author !== get_current_user_id()) {
		return 'You can only edit your own posts.';
	}

	return $edit_screen_error;
}, 10, 2);
```

## Related

* [`wpce_before_edit_screen`](./wpce-before-edit-screen)
