Welcome to this step-by-step guide on creating a membership site using the powerful combination of Webflow, Memberstack, and Xano. We'll walk through the entire process, from setting up the necessary accounts and integrations to displaying content based on a user's membership plan. Let's get started!
Prerequisites
Before we dive in, make sure you have the following:
- A Webflow account
- A Memberstack account
- A Xano account (sign up for a free account at xano.com)
Setting Up Xano
- Log in to your Xano account and navigate to the dashboard.
- Click on "Get Started" and name your workspace "WMX" (short for Webflow, Memberstack, and Xano).
- From the Marketplace, select the "WMX Webflow MemberStack Xano" template.
- Click "Manage" and provide the following keys:
- Webflow API key
- Webflow Member CMS Collection ID
- Memberstack API key
Obtaining the Webflow API Key
- In Webflow, go to your project settings and click on "Integrations."
- Scroll down and click "Create or Generate a New API Token" under "API Access."
- Copy the generated API key and paste it into the corresponding field in Xano.
Setting Up the Webflow CMS Collection
- In Webflow, add a new CMS Collection named "members."
- Add the following fields: First Name, Last Name, and Email.
- Create the collection and copy its ID.
- Paste the Collection ID into the "Webflow Member CMS Collection ID" field in Xano.
Obtaining the Memberstack API Key
- In Memberstack, go to "Power-ups" > "Integrations" > "Custom Integrations."
- Create a new API key.
- Copy the API key and paste it into the "Memberstack API Key" field in Xano.
- Click "Update" in Xano.
Configuring Memberstack Webhooks
- In Memberstack, go to "Settings" > "Webhooks."
- Delete any existing webhooks.
- In Xano, navigate to the API section and copy the "memberstack member post" endpoint URL.
- Back in Memberstack, add a new webhook with the copied URL and set it to trigger on "New Member."
Setting Up Membership Plans in Xano
- In Xano, go to the "Database Tables" section.
- Open the "Plan" table and add your membership plans from Memberstack, including their respective IDs.
- In the "Items" column, enter the item IDs from the "Item" table that should be associated with each plan.
Displaying Membership Content in Webflow
- In Webflow, locate the page where you want to display membership content (e.g., "Account Home Basic").
- Add a container element with an ID (e.g., "cards-container") where the membership items will be displayed.
- Add a sample card element that will be used as a template for displaying each item. Hide this sample card using the "Hide" option.
- In the page settings, scroll down to the "Before Tag" section and paste the following JavaScript code, replacing the API endpoint URL with your own:
javascript
<script>
let endpoint = 'https://example.xano.io/api/public/itemsOfAMember?webflowMemberId=';
function loadItems() {
let webflowMemberId = document.getElementById('Webflow-member-ID');
let request = new XMLHttpRequest();
request.open('GET', endpoint + webflowMemberId.dataset.msMember);
request.send();
request.onload = () => {
if (request.status === 200) {
let data = JSON.parse(request.response);
let cardsContainer = document.getElementById('cards-container');
let sampleCard = document.getElementsByClassName('sample-card')[0];
data.forEach(item => {
let card = sampleCard.cloneNode(true);
card.getElementsByTagName('img')[0].src = item.imageUrl;
card.getElementsByTagName('h3')[0].textContent = item.name;
card.getElementsByTagName('p')[0].textContent = item.description;
card.style.display = 'block';
cardsContainer.appendChild(card);
});
}
};
}
// Wait for the Webflow Member ID to be loaded
setTimeout(loadItems, 250);
</script>
- In the same page, add a hidden div with the following attribute: `data-ms-member="Webflow-member-ID"`. This will allow the JavaScript to access the Webflow Member ID.
- Repeat steps 2-5 for any other membership plan pages (e.g., "Account Home Premium").
- Publish your Webflow site.
Testing the Membership Site
- Sign up for a membership plan on your Webflow site.
- After successful registration, navigate to the corresponding membership plan page (e.g., "Account Home Basic" or "Account Home Premium").
- You should see the membership items associated with your plan displayed on the page.
Congratulations! You've successfully set up a membership site using Webflow, Memberstack, and Xano. Users can now sign up, log in, and view content based on their membership plan.