Skip to content

Instantly share code, notes, and snippets.

@mclarenmervin
Created July 23, 2024 09:39
Show Gist options
  • Save mclarenmervin/3946316167044f93ad2bc03b1884b334 to your computer and use it in GitHub Desktop.
Save mclarenmervin/3946316167044f93ad2bc03b1884b334 to your computer and use it in GitHub Desktop.
On switching theme send mail to a specific email
<?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