nican VIP
Total posts: 392
30 Apr 2018 10:03

Hello, I love the [PAID] tags feature to show/hide content based on user subscription, but it's not working well to show/hide big parts of the page, it breaks the layout if used in that way. For this reason I am switching to RegularLabs Conditional Content extension.

Thsi extension has a custom PHP settings and the description reads like this:

Enter a piece of PHP code to evaluate. The code must return the value true or false. For instance: return ( $user->name == 'Peter van Westen' );

Could you suggest in case of Emerald what would be the PHP code to use? It has to check a user active subscription and return a true or false value.

I will hire a developer to work on this part of the project and point him to your suggestion here, plus I will post here the full solution once is developed in case someone else need something similar.

thank you

Last Modified: 24 Sep 2021

pepperstreet VIP
Total posts: 3,834
30 Apr 2018 17:29

Hello nican, in the following topic Sergey mentioned the Emerald API:

His comment and example:

Where 1,2,3 are IDs of the plans that are require to have to hide ads.

if(!EmeraldApi::hasSubscription(array(1,2,3), null, $item->user_id, false, false))

nican VIP
Total posts: 392
01 May 2018 09:01

Thank you Pepperstreet, I'll definitely have to hire a developer from this point on, he will figure out if this solution can work.

Total posts: 13,743
01 May 2018 14:15

I think the problem why it breaks layout, you place some closing or opening <div> tag inside [PAID] without it is pair and thus sreate shift in hierarhy.

It should work perfectly if you use it right.

nican VIP
Total posts: 392
02 May 2018 13:12

It's not just that, the problem arises when I try to hide/show very long pieces of content, it works fine to just hide a p, but if I hide something where there are several div,p,table etc... then there are always problems. I think it's some kind of bug because when I load the pages sometimes it works fine, some other it breaks the layout.

Anyway, the reason why I prefer Conditional Content extension is not only that it always works fine, it also allows me to hide/show content based on more than 1 condition.

In my case I need to show content if - User has na active Emerald subscription OR - User has bought a certain Hikashop product

Sergey, can you confirm that the code suggested by Pepperstreet is the one I need to use with Conditional Content Extension? I am not a developer but will point here someone as soon as I hire them.

Conditional Content tutorial reads: Enter a piece of PHP code to evaluate. The code must return the value true or false. For instance: return ( $user->name == 'Peter van Westen' );

Thank you

Powered by Cobalt