• 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]

Viewing 1 replies (of 1 total)
  • Plugin Author eskapism

    (@eskapism)

    It sounds like the hook “wp_footer” is fired twice, once for the current page and then again for the most recent blog post. It should not fire for the latest blog post, so it sounds to me like the problem is there somehow. Is it a widget or something that shows the latest blog post on the screen? I would check that code to see that it’s not wrongly firing the wp_footer hook.

Viewing 1 replies (of 1 total)
  • The topic ‘Track user activity: pages visited’ is closed to new replies.