-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathchange-admin-email.php
More file actions
32 lines (26 loc) · 998 Bytes
/
change-admin-email.php
File metadata and controls
32 lines (26 loc) · 998 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<?php
/**
* Plugin Name: Change Admin Email
* Description: Changes the admin email address if it hasn't been changed already without triggering email validation.
* Version: 1.0.0
* Type: mu-plugin
* Status: Complete
*/
// Ensure this is being run within the context of WordPress.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}
function change_admin_email() {
// Define the new admin email.
$new_admin_email = 'newadmin@example.com';
// Get the current admin email.
$current_admin_email = get_option( 'admin_email' );
// Check if the current admin email is already set to the new email.
if ( $current_admin_email !== $new_admin_email ) {
// Update the admin email without triggering email validation.
remove_action( 'update_option_new_admin_email', 'update_option_new_admin_email' );
update_option( 'admin_email', $new_admin_email );
}
}
// Hook the function to WordPress initialization action.
add_action( 'init', 'change_admin_email' );