# Lock the Site URL and Admin Email

> Ignores changes to the WordPress Address, Site Address and administration email made from the dashboard, a common target after an account takeover.

- Type: PHP
- Runs: Run everywhere
- Category: [Security](https://wpide.com/library/category/security/)
- Tags: security, settings, hardening
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/lock-site-url-admin-email/

## Code

```php
foreach ( array( 'siteurl', 'home', 'admin_email', 'new_admin_email' ) as $wpide_locked_option ) {
    add_filter( "pre_update_option_{$wpide_locked_option}", function ( $value, $old_value ) {
        return $old_value;
    }, 99, 2 );
}

add_action( 'admin_notices', function () {
    $screen = get_current_screen();

    if ( $screen && 'options-general' === $screen->id ) {
        echo '<div class="notice notice-info"><p>The site addresses and administration email are locked by a code snippet and cannot be changed here.</p></div>';
    }
} );
```

## Notes

Deactivate the snippet before a planned domain change or admin email update.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Lock the Site URL and Admin Email" 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/
