Track user activity: pages visited
-
I am trying to add to the history log the pages a logged-in user visits. I used the code you posted on another post:
add_action(‘wp_footer’, ‘trackUserActivity’);
function trackUserActivity() {
$user = wp_get_current_user();
$user_email = $user->user_email;
$page_title = get_the_title();
$msg = “User $user_email viewed page $page_title”;
apply_filters(‘simple_history_log’, $msg);
}However, this doesn’t work exactly right and I can’t see how to fix it. The above code does log each page a logged-in user visits, but for every page a user visits, the code also sends a message indicating the user visited the most recently created blog post, when this isn’t the case. Any ideas how the code should be tweaked?
The page I need help with: [log in to see the link]
- The topic ‘Track user activity: pages visited’ is closed to new replies.