Run external JS that uses is / isn’t MS member AND Webflow CMS attributes

Hi all.

I’m looking for a solution to the following problem.

My Webflow site (leonardoenglish.com) uses MS to allow members access to transcripts and key vocabulary for podcasts for English learners.

So far so good - all implemented at a basic level.

However, I’ve recently implemented some custom JS to ‘animate’ the transcripts (see here: https://www.leonardoenglish.com/podcasts/how-to-use-podcasts-to-learn-english-like-a-boss) using an external script.

Each podcast can either be:

  • Free transcript (anyone can access it, no membership required)
  • Pro transcript (membership is required)

The solution I’m using at the moment is as follows:

  • ‘Pro’ content div is hidden to non-pro members, but the script still runs (it adds content to a hidden div). When a non-pro member sees pro content, they get a message telling them to upgrade.
  • ‘Free’ content div - is hidden when marked as ‘Pro’, but the script still runs, again to a hidden div

Inelegant, I know.

With this external script, I’m trying to find a solution to do the following:

<script> If is a valid MS member (

Run script as normal

) If isn’t a member ( 

If podcast CMS attribute is ‘free’ (

Run script as normal

) Else (

Run a different script

)

</script>

However, I can’t see how you would access whether the CMS attribute of the podcast is ‘free’ (appreciate this is probably more a webflow question than MS).

And if this isn’t possible, would you just have to have 2 separate custom code snippets in webflow, one of which is hidden when free, the other shown when free?

Wondering if anyone has come up against a similar problem….

Hi Alastair,

You should be able to do this with our JS hook. https://help.memberstack.io/post/front-end-api

Using our hook, you can see what membership a member is currently subscribed to, and from there could run your existing code.

I recommend reading through that link to see all the options / information that is available.

OK thanks Tyler - I’ll do that.

Let me know if you have any questions about it :grinning: