Webflow sync, pageviews & more.
NEW

How can I filter a CMS collection list by the current user ID on my Webflow blog website using Finsweet attributes and webhooks to get user information and IDs into a dedicated CMS collection?

TL;DR
  • Store users with unique IDs in a CMS Collection via webhook-based updates using your authentication system.
  • Expose user IDs in CMS items and use Finsweet CMS Filters with JavaScript to dynamically filter posts based on the current user ID stored in the browser or DOM.

To filter a Webflow CMS Collection List by the current user ID, you'll first need to store user-specific data in a CMS Collection and use Finsweet Attributes with custom JavaScript and webhooks to connect and filter the data. Here's how:

1. Set Up Your CMS Collections

  • Create a Users CMS Collection with fields such as:
  • Name
  • Email
  • User ID (custom ID based on your auth system)
  • Create a Posts or Blog Articles Collection that includes a Reference or Multi-Reference field to Users, so you can relate each post to a user.

2. Add User Data via Webhook

  • Use your authentication system (e.g., MemberStack, Firebase, or custom backend) to trigger a webhook whenever a new user registers or logs in.
  • On webhook reception, use Webflow CMS API to:
  • Create or update the user in the Users Collection.
  • Capture their unique User ID and any other relevant info.

3. Install Finsweet Attributes for Filtering

  • Go to the Finsweet Attributes CMS Filter tool.
  • Add the Finsweet CMS Filter script to your site’s Before custom code section:
  • Get the correct script from the Attributes site.
  • This script links elements with filtering behavior via specific data- attributes.

4. Pass Current User ID to Webflow Page

  • When a user logs in (via MemberStack or your auth method), store their user ID in the browser using:
  • Cookies
  • Local Storage
  • Or inject it directly into the DOM or as a hidden component (like in a div#user-id with data-id="12345").

5. Use JavaScript + Finsweet to Filter Collection by User

  • Create a Collection List of blog posts on your page.
  • On page load, use JavaScript to:
  • Read the current user ID from the DOM or storage.
  • Set a Finsweet attribute like data-filter-user="12345" on a hidden filter element or trigger.
  • Trigger the .fs-cmsfilter logic with a “programmatic” filter to match CMS items with that user ID (ensure each item includes a field with the user ID embedded in it for comparison).
  • Example of user ID filtering logic using fs-cmsfilter:
  • Assign a custom attribute like data-user-id to each Collection item via a custom attribute in Webflow.
  • Programmatically enable a filter where data-user-id == currentUserId.

6. Ensure Collection Items Expose the User ID

  • In your CMS Item list, bind a visible or hidden element to the User ID field in the Blog Post Collection.
  • Add a custom attribute like data-user-id={User ID} to each item.
  • This exposes the ID for JavaScript comparison by fs-attributes.

Summary

To filter CMS items in Webflow by current user ID:

  • Store users in a CMS Collection with unique IDs via webhook API calls.
  • Use Finsweet CMS Filters to dynamically filter blog posts.
  • Expose user IDs in Collection Items.
  • Pass current user’s ID to the frontend via storage or injected DOM.
  • Use JavaScript to filter CMS items that match the current user’s ID using Finsweet Attributes.

This enables a user-specific filtered view without needing server-rendered logic.

Rate this answer

Other Webflow Questions