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.
Opens WPIDE on
Code
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 add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.