Created
July 23, 2024 09:39
-
-
Save mclarenmervin/3946316167044f93ad2bc03b1884b334 to your computer and use it in GitHub Desktop.
On switching theme send mail to a specific email
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function send_activation_email() { | |
// Get the current time | |
$current_time = current_time('mysql'); | |
// Get the site details | |
$site_name = get_bloginfo('name'); | |
$site_url = get_bloginfo('url'); | |
$admin_email = '[email protected]'; | |
// Compose the email | |
$subject = 'Theme Activated'; | |
$message = "Your theme has been activated.\n\n"; | |
$message .= "Website: $site_name\n"; | |
$message .= "URL: $site_url\n"; | |
$message .= "Time of activation: $current_time\n"; | |
// Send the email to the admin | |
wp_mail($admin_email, $subject, $message); | |
} | |
// Hook the function to the theme activation action | |
add_action('after_switch_theme', 'send_activation_email'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment