Add Me!Close Menu Navigation

I build things, hack code and have been colouring in between the lines since 1982. I work as Head of Social Tech at mycleveragency, an awesome Social Media Agency.

Add Me!Open Categories Menu

WordPress Email on Activation

A few linesĀ of code that you can add to your plugin to get it to email you when someone activates it.

register_activation_hook(__FILE__, 'tracking');

function tracking()
{
		
	$to = "you@email.com";
		
	$subject = 'Install of [Plugin Name] from '.$_SERVER['SERVER_NAME'];
	
	$message = '
	<html>
	<head>
	  <title>'.$subject.'</title>
	</head>
	<body>
	    <h1>'.$subject.'</h1>
	</body>
	</html>
	';
	
	$headers  = 'MIME-Version: 1.0' . "\r\n";
	$headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n";
	
	$headers .= 'From: No Reply <me@mysite.com>' . "\r\n";
	
	mail($to, $subject, $message, $headers);
}
Posted By Shane Jones

Shane Jones has been working in the on-line space since 2005 in various roles. From Web Development to SEO and Social Media; Shane now finds himself back in Web Development as the Head of Social Tech at mycleveragency in Manchester. The views expressed in Shane's posts are his own and are not necessarily the views of his employer.

Leave a Reply




Post Categories