How to migrate WordPress members with expiring one-time paid plans to Webflow? Answered

I have a customer who needs to migrate from Wordpress to Webflow.

They have a bunch of members with one-time paid plans that are set to expire 🤔 Normally I would have them put the members on free plans to grant access, but these need to expire... has anyone experienced this before?

My fav solution right now is to have them:

  1. Import onto legacy free plans
  2. Import the subscription end date as a custom field.
  3. Write some custom code for the website that:
  • If the member has a legacy plan AND the end date is in the past THEN put remove the free plan so they need to upgrade to continue.

I talked it over with Rey, and came up with this. Did it handle the timestamp conversion correctly?🤔

Custom Script to Remove Legacy Free Plan Using Custom Fields

<!-- :blue_heart: CUSTOM SCRIPT TO REMOVE LEGACY FREE PLAN AFTER EXPIRATION DATE :blue_heart: --> 
<script>
let legacyFreePlanId = "your_legacy_free_plan_ID"; // Replace with your actual legacy free plan ID
document.addEventListener("DOMContentLoaded", async function() { const memberstack = window.$memberstackDom;

// Fetch the member's data
const member = await memberstack.getMember();

// Check if the member has the legacy free plan
if (member && member.planConnections) {
const hasLegacyPlan =
member.planConnections.some(planConnection =>
planConnection.planId === legacyFreePlanId);

if (hasLegacyPlan) {
// Get the subscription end date from the custom field const subscriptionEndDate = new Date(member['subscription-end-date'] * 1000); // Convert Unix timestamp to Date
const currentDate = new Date();

if (currentDate > subscriptionEndDate) {
// If the subscription end date has passed, remove the legacy free plan
memberstack.removePlan({
planId: legacyFreePlanId
}).then(() => {
// Redirect to a page informing the user that their access has expired
window.location.href = "/access-expired"; // Change to your desired redirect URL
}).catch(error => {
console.error("Error removing plan:", error);
});
}
}
}
});
</script>

Implementation:

  1. Custom Field for Subscription End Date: Ensure that the custom field name for the subscription end date matches what you have set up in Memberstack.
  1. Add this script to your Webflow project, ideally before the closing </body> tag on pages where you want to check the member's access.

MIchael Rose can you post updates here as you test?

Comments

4 comments

  • Comment author
    MIchael Rose

    I almost asked if I should do that. I'll move my last DM here.

    So I added the script to two pages. One is in the screenshot with the inspector open:

    I'm just wondering if I should use a different date format. My custom field entry is 1/1/2025.

    0
  • Comment author
    Duncan from Memberstack

    Try this instead 1735689600
    That's the same date in Unix

    I think that's how the dates will be formatted in Stripe... but we'll need to confirm

    0
  • Comment author
    A J

    Hey MIchael Rose, made few changes to the script above. Can you try this code on the page and see if it works?

    <!-- CUSTOM SCRIPT TO REMOVE LEGACY FREE PLAN AFTER EXPIRATION DATE :blue_heart: -->
    <script>
    let legacyFreePlanId = "YOUR-PLAN-ID"; // Replace with your actual legacy free plan ID
    document.addEventListener("DOMContentLoaded", async function() {
      const memberstack = window.$memberstackDom;
    
      // Fetch the member's data
      const memberResponse = await memberstack.getCurrentMember();
    
      if (memberResponse && memberResponse.data) {
        const member = memberResponse.data;
        const hasLegacyPlan = member.planConnections.some(planConnection => planConnection.planId === legacyFreePlanId);
    
        if (hasLegacyPlan) {
          // Get the subscription end date from the custom field
          const subscriptionEndDate = new Date(member.customFields['subscription-end-date'] * 1000); // Convert Unix timestamp to Date
          console.log(subscriptionEndDate);
          const currentDate = new Date();
    
          if (currentDate > subscriptionEndDate) {
            // If the subscription end date has passed, remove the legacy free plan
            memberstack.removePlan({
              planId: legacyFreePlanId
            }).then(() => {
              // Redirect to a page informing the user that their access has expired
              window.location.href = "/signup"; // Change to your desired redirect URL
            }).catch(error => {
              console.error("Error removing plan:", error);
            });
          }
        }
      }
    });
    </script> 
    
    0
  • Comment author
    MIchael Rose

    A J Yes! That worked!! 🎉🙌

    Thank you both SOOOO much for your help! ❤️

    0

Please sign in to leave a comment.