---
title: "Showing entries added since a user&#8217;s last login"
date: 2026-11-10
updated: 2026-11-10
author: "Rafael Bennemann"
link: "https://www.gravitykit.com/docs/gravityview-pro/advanced-filter/showing-entries-added-since-last-login/"
category: "GravityView Pro > Advanced Filter"
---

A View can list only the entries added since the logged-in user's last visit, such as new notices on a member dashboard. WordPress keeps no lasting record of when each user logs in, so a short snippet saves the time, and an [Advanced Filter](https://www.gravitykit.com/docs/gravityview-pro/advanced-filter/getting-started-with-the-advanced-filtering-extension/) condition compares each entry's date with it.

![A member dashboard with a New since your last visit table listing two notices above the table of all notices](https://www.gravitykit.com/wp-content/uploads/2026/11/gravityview-member-dashboard-new-since-last-visit.png)

## Step 1: Save each user's login time

Add this snippet to your site. Every time a user logs in, it saves the time of that login and keeps the time of the login before it:

```
add_action( 'wp_login', function ( $user_login, $user ) {
    $now     = current_time( 'mysql', true ); // UTC, like entry dates.
    $current = get_user_meta( $user->ID, 'current_login', true );

    // Keep the login before this one, so new entries stay listed.
    $previous = $current ? $current : $now;

    update_user_meta( $user->ID, 'previous_login', $previous );
    update_user_meta( $user->ID, 'current_login', $now );
}, 10, 2 );
```

**Note**: [Adding custom PHP code snippets to your website](https://www.gravitykit.com/docs/gravityview/customizing-your-views/where-to-put-code-samples/) shows where to put this code.

The View compares entries with `previous_login`, the login before the current one. Logging in doesn't clear the list: entries added since the last visit stay listed for this whole visit, and drop off at the next login.

Both times are saved in UTC, the time zone Gravity Forms uses for entry dates, so the comparison is right whatever your site's time zone.

## Step 2: Filter the View by the saved time

- Edit the View and open the **Filter & Sort** tab in the **Settings** box.
- Under **Advanced Filter**, click **+ Condition**.
- Choose **Entry Date** as the field and **is after** as the operator.
- In the value list, choose **Custom Value**, then type `{user:previous_login}`. The merge tag list doesn't offer it, so type it in.
- Click **Update**.

![The Advanced Filter section with the condition Entry Date is after {user:previous_login}](https://www.gravitykit.com/wp-content/uploads/2026/11/gravityview-advanced-filter-entry-date-after-previous-login-merge-tag.png)
`{user:previous_login}` is the [`{user}` merge tag](https://www.gravitykit.com/docs/gravityview/merge-tags/the-createdby-merge-tag/) with the meta key the snippet saves

## Step 3: Show the list only when something is new

To use the View as a "New since your last visit" box above a full list:

- In the View's **Settings** box, open the **Multiple Entries** tab and set **No Entries Behavior** to **Hide the View**.
- Embed this View on the page, above the View that lists all entries. [Embedding a View on a page or post](https://www.gravitykit.com/docs/gravityview/getting-started/embedding-a-view-on-a-page-or-post/) shows how.

![The Multiple Entries tab of the View's Settings box with No Entries Behavior set to Hide the View and outlined](https://www.gravitykit.com/wp-content/uploads/2026/11/gravityview-no-entries-behavior-hide-view-setting.png)
*When nothing is new for the user, the box isn't shown*

## Users with no saved login time

Until a user logs in after you add the snippet, `{user:previous_login}` is empty and the View lists every entry for them. At that first login, both saved times are the login itself, so the list starts empty and fills with the entries added after it.

Visitors who aren't logged in have no saved time either, so they see every entry. To show the View to logged-in users only, see [Restricting a View to logged-in users or user roles](https://www.gravitykit.com/docs/gravityview/filter-and-sort-results/restrict-view-content-to-members/).