Display the users plan name Answered

Post author
Ryan Fleming

Are we able to display the users plan name yet? Ie: 'Your Plan - {displays current plan name}'

Our member dashboard ideally would include this so the user can immediately see which plan level they're on. Help center had a post 9 months ago suggesting - data-ms-member='membership.name'. But that doesn't seem to work.



  • Comment author
    Julian Galluzzo

    by default this wouldnt work because members can have more than one plan - that being said, if your setup is such that members will only have one plan at a time, you can probably do this with javascript - just look at the plan connections in the local storage and then display it πŸ™Œ

    Even if they do have multiple plans, this would be possible. I might make a Memberscript for this soon πŸ™‚

  • Comment author
    Duncan Hamra

    Tyler Bell Is plan information (like name, price, etc.) available in the frontend now?

    Last time I checked it was not available.

    Ryan Fleming I can’t find that help center article πŸ€” Do you have a link handy?

    Duncan Hamra https://support.memberstack.com/hc/en-us/articles/4408627868699-How-can-I-show-a-members-current-membership-name-and-price-

  • Comment author
    Raquel Lopez

    I worked once on a use case where I needed to send the planId for analytics purposes. In that particular case, there were few planIds that were not shared, I mean, the user either had to always be on planA, planB, or planC, among other planIds for other reasons. I call them mainPlanIds.

    If this is your case, where you're handling the main plan ids using Memberstack logic, you can use this snippet. Replacing only the elements inside mainPlanIds array and yourElem selector (let's say the element that you want to show the plan title) πŸ™‚

    This code will execute whenever you include it. You could test it out using your dev console first.

    // First declare which plan ids are your main ones, meaning that you're using MemberStack logic to make sure // the user does not have these plans at the same time and the user ALWAYS will have one of these assigned window.mainPlansIds = [ // Please replace this with your current plan ids "pln_123", "pln_456", "pln_789" ]; // Request MemberStack the user information $memberstackDom.getCurrentMember().then(({ data }) => { // Checks if member is logged in if (data) { // Get which of the main plan ids list the user has const mainPlan = data.planConnections.find((plan) => { return mainPlansIds.includes(plan.planId); }); if (!mainPlan) { throw new Error("Plan Id does not exist in main list"); // Stops execution if plan id is not found } // Request the info of the current plan $memberstackDom.getPlan({ planId: mainPlan.planId }).then(({ data }) => { const planName = data.name; // Proceed with DOM modification using the planName $(yourElem).text(planName) // Replace yourElem with your preferred selector }) } }).catch((err) => { console.error(err); });



Please sign in to leave a comment.