You can trigger wp_mail()
to send you an email when you have a visitor, although you may end up getting flooded with emails since it’ll email you every time a page is viewed.
/**
* Send an email with every visit.
*/
function wpse113069_email_me_every_visit() {
wp_mail( '[email protected]', 'You had a visitor...', 'Yea, someone was on your site!' );
}
add_action( 'wp', 'wpse113069_email_me_every_visit' );
You can also use is_user_logged_in()
to extend this to include the page/post, the date & time of the visit, etc., or to customize the notification based on if someone is logged in or is an anonymous visitor.
/**
* Send a different email based on if a visitor is signed into the site.
*/
function wpse113069_email_me() {
$msg = 'An anonymous visitor visited!';
if ( is_user_logged_in() ) {
$msg = 'A member visited!';
}
wp_mail( '[email protected]', 'You had a visitor...', $msg );
}
add_action( 'wp', 'wpse113069_email_me' );