How to set a Cookie or MetaTag for premium users in WordPress?

[ad_1]

Hi all,

I’d like to offer a section of my Website which does not show Ads for premium users. The Ads publisher I use, can disable Ads when a Cookie or MetaData is available.

Can you recommend a WordPress plugin that sets a Cookies or MetaData for users that have become “premium” users ? (upon payment)

Thanks

[ad_2]
1 Comment
  1. What are you using to track that a user has “premium”?

    This could probably be done with a simple piece of Themes code in functions.php.

    Check if the user belongs to “Premium” user role group, and if so, set your desired cookie using PHP.

    Just have to ensure that your paid users are added to a custom role group like “premium_users” when the checkout of purchase is complete.

    Can be done with a few lines of code.

    And my suggestion is to use “WP Snippets” plugin to add your PHP code instead of modifying the themes files directly.

    PS. if you ask ChatGPT it can probably give you the code that you need as well.

    Add user to “subscribers” group when they purchase item #12345 in WooCommerce:

    And set cookie “no_ads_cookie” when logged-in user in “subscribers” group views a page:

    Paste both of these into functions.php of your themes files. Or add it using WP Snippets plugin as PHP when user is “viewing front end only”.

    Change the cookie name and product id as needed.

    You’ll also need a subscription management plugin which will remove users from “subscribers” group when their subscription expires.

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer