你可以触发wp_mail()
当你有访客时给你发邮件,尽管你可能会被邮件淹没,因为它会给你发邮件every time 将查看页面。
/**
* 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\' );
您还可以使用
is_user_logged_in()
要扩展此内容以包括页面/帖子,请输入日期和;访问时间等,或根据是否有人登录或是匿名访问者自定义通知。
/**
* 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\' );