Make members-only content public after a time period

Hey! :wave:

I’m planning to use the members functionality in Ghost for premium content. Something I’d like to support is content that is initially released to premium members, then after a period of time is unlocked to the public. Early access content, or however you’d prefer to phrase it.

Is this supported by Ghost as a feature? If not, would it be possible to mark early access content in some way (internal tag?) and then set up an automation / script (via the API?) to switch it from members-only to public after some fixed time?

I’ve had a search around and I can’t see this mentioned anywhere. Any pointers in the right direction will be appreciated,

Thanks,
Robin

Look who it is! :slight_smile:

Theoretically this should be possible I think — @Hannah probably has a better idea. 14 years and we’re back on a forum like nothing changed :joy:

1 Like

Ha! Yeah half a life-time later and we’re back on the forums. I miss those simpler times! Feels like forever since we were tinkering on the pre-Ghost prototype in my flat.

I’ve had a look at the docs and I think I can set up something manual that changes the post permissions after a period of time. Also wondering if it might be possible to leave a post as members-only but have something in the template to ignore that if it has an internal tag (eg. #early-access) and a fixed time has elapsed since the publish date.

it’d be good to hear if there’s a simpler / more legit way of doing it rather than running a cron job.

Hey you :wave: forums are the best :joy:

Access is a core concept in the API, so the template won’t even get the data if you don’t have access, therefore there’s no way to keep the access be members-only and get the template to not respect it :grimacing:

Buuut it’s totally possible to update the access level after a period of time via the API - it’s undocumented because Beta, but in essence you have to change the posts visibility to public.

You’re actually the second person I’ve had ask about something like this recently :slight_smile: The other use case was sponsored featured posts, e.g. setting a post to featured and adding a #sponsored tag, and then removing the featured flag after 30 days.

Both of these things are really easy to do with the API, we just need a way to trigger it. I figured the easiest way to set this up is with GitHub Actions, so I chucked one together that can solve either use-case:

It’s only got a basic README atm, but the idea is that you can setup a workflow and pass in configuration for what to change and after what time period. I tested it on my site running it every 5 minutes example here.

The neat thing about GitHub Actions is you can setup this workflow alongside the deploy theme workflow, using the same set of secrets to talk to the API, so there’s minimal additional config. You don’t have to maintain anything and it’s all preset to give nice output like this:

If you didn’t want to use GitHub Actions, you can pull out all the necessary API code from here:

3 Likes