Invision Community 5: A video walkthrough creating a custom theme and homepage By Matt Thursday at 04:02 PM
Graeme S. Posted January 21, 2020 Posted January 21, 2020 Hi all, I've had a look around but this is something that's out of my technical expertise. I am using Ezoic to serve ads on my site and I want to hide ads for subscribers. I can do this by setting up a custom cookie (e.g. Cookie called WebsiteEzoicAds with value NoAds). Then I would just tell Ezoic to hide ads from users with that cookie. I know how to trigger code for certain groups, but not sure what to use to create/set the new cookie {{if in_array( member.member_group_id, array(2,4,3) )}} // Set cookie in here {{endif}}
bfarber Posted January 22, 2020 Posted January 22, 2020 {{if in_array( member.member_group_id, array(2,4,3) )}} {{\IPS\Request::i()->setCooke( 'name', 'value' );}} {{endif}} Note that name will have a prefix (ips4_ by default) using this method. Also, this would result in a cookie only readable by HTTP...if you need it available for javascript, you would need to call ->setCookie( 'name', 'value', NULL, TRUE ); And finally, that NULL there in my last example is the expiration - by default the method will set a cookie only for the current browser session (so it will be cleared when you close the browser). If you need the cookie to persist, you would need to pass an \IPS\DateTime object there representing the expiration. Or you could just use the core php method instead of our setCookie() wrapper if you need some more control.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.