Disable ads if the user has an active subscription

Hi, I have recently started my blog with ghost and I have implemented adsense ads. I would like to know if there is a way to make the ads on my page disappear if the user is logged in and has an active subscription.

Thank you very much in advance.

In your theme, this snippet will only output if the current visitor is not a logged-in member

{{^if @member}}
  // ad code
{{/if}}
 

Sorry, I missed that you said “has an active subscription” - the snippet above is for any logged-in member, for paid members only, use:

{{^if @member.paid}}
  // ad code
{{/if}}
2 Likes

The problem is that I’m using the insert script feature so I don’t know how to put the script.

Do you mean code injection inside ghost admin? Yeah, it wouldn’t work there - you’d need to edit your theme to do this

What file I need to edit.

default.hbs

partials/post-card.hbs

Wow. So this mean it’s possible to create ads free blog if it’s paid. Something like pay to remove ads. Nice one @John . Was about to suggest this. But it’s there already.

1 Like

Thanks for this! I was trying to get this to work using code injection on the admin panel as I’m using a hosted theme (and I really need this to work). Is there any way to use this ({{^if @member.paid}}) in code injection or other places on a page/post without a custom/self-hosted theme?

Due to the maintenance and updates, I’m trying to avoid forking a theme at all costs. If this is not an option currently, can we suggest it?

This is amazing thanks @John

Is there a way to insert this into html cards?

It’s not possible to do this anywhere in admin — has to be in theme files