# Stop Authors Editing Posts After They Are Published

> Lets authors and contributors write and submit posts as usual, but once a post is published only editors and administrators can change it, which keeps approved content approved.

- Type: PHP
- Runs: Run everywhere
- Category: [Content](https://wpide.com/library/category/content/)
- Tags: editorial, permissions, publishing
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/content-lock-published-for-authors/

## Code

```php
// Days after publishing during which authors may still edit (0 = never).
$wpide_lock_after_days = 0;

add_filter( 'map_meta_cap', function ( $caps, $cap, $user_id, $args ) use ( $wpide_lock_after_days ) {
    if ( ! in_array( $cap, array( 'edit_post', 'delete_post' ), true ) || empty( $args[0] ) ) {
        return $caps;
    }

    $post = get_post( (int) $args[0] );
    if ( ! $post || 'publish' !== $post->post_status || 'post' !== $post->post_type ) {
        return $caps;
    }

    // Editors and administrators are never locked out.
    if ( user_can( $user_id, 'edit_others_posts' ) ) {
        return $caps;
    }

    if ( $wpide_lock_after_days && get_post_time( 'U', true, $post ) > time() - $wpide_lock_after_days * DAY_IN_SECONDS ) {
        return $caps;
    }

    $caps[] = 'do_not_allow';
    return $caps;
}, 10, 4 );
```

## Notes

Set $wpide_lock_after_days to give authors a grace period, for example 1 day to fix typos.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Stop Authors Editing Posts After They Are Published" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
