[SOLVED] Hide Content depending on CBsubs Plan

12 years 1 month ago - 12 years 1 month ago #197501 by pixelkraft
Hi!

I installed the CB Content Bot Plugin and now want to hide or show content fragments, depending on the Plan of the User. I have 3 plans.

I found the tutorial of the substitution usage, but how can I access the plan ID?

I think of something like
[cb:if plan_id="1"]This is confidential information for Plan-1-Subscribers only.[/cb:if]

Will this work somehow? How is the variable for the plan_ids?

Thx for your support! B)

Please Log in to join the conversation.

12 years 1 month ago #197517 by krileon
Replied by krileon on topic Re: Hide Content depending on CBsubs Plan
CBSubs doesn't have global substitutions or anything of the sort. So no, that will not work. You'd need to use CB Query Field to first query the database and get a users subscription and plan ID then use that query field in your substitutions. Please note the plugins description and the incubator overview page as all substitutions in a Joomla article when using CB Content Bot must be surrounded with {cb:} (e.g. {cb:[username]}).

Nick has provided a nice tutorial detailing similar to your case below.

www.joomlapolis.com/support/tutorials/107-use-cases/18240-time-released-subscription-content-solution


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 1 month ago - 12 years 1 month ago #197820 by pixelkraft
Replied by pixelkraft on topic Re: Hide Content depending on CBsubs Plan
edit:

I found a way the query worked out. Now the SQL query of my field named "cb_subscription" is

SELECT `plan_id` FROM `#__cbsubs_subscriptions` WHERE `user_id` = USER_ID


And my content is

{cb:[cb:if cb_subscription="2"]Welcome to Plan 2[/cb:if]}


But one question remains: I have some users which have Plan 1 and Plan 2. So the user-IDs appear more than once in the sql table.

This is a problem, because for a user, who subscribed to plan 1, 2 and 3, the sql query just returns "2".

How can I modify the query to get all plan-IDs of a user?

Thanks for your help!

Please Log in to join the conversation.

12 years 1 month ago #197850 by krileon
Replied by krileon on topic Re: Hide Content depending on CBsubs Plan
The below will give you a |*| separated list of plan ids for a user.
SELECT GROUP_CONCAT( `plan_id` SEPARATOR '|*|' ) AS ids FROM `#__cbsubs_subscriptions` WHERE `user_id` = USER_ID GROUP BY `user_id`

Example output: 7|*|3|*|18|*|6


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

12 years 1 month ago #197929 by pixelkraft
Replied by pixelkraft on topic Re: Hide Content depending on CBsubs Plan
Thanks!

That works out for me! For a user with Plans 1, 2 and 3 the query returns

1|*|2|*|3

But now I have the problem how to use the "if".
I tried

{cb:[cb:if cb_subscription includes "3"]You are in Plan 3[/cb:if]}


But this does not work. Do I need another query than "3" ? Maybe a regex? I also tried a comma or space separated list of IDs, but it didn`t work anyway!

Do you have an idea?

Thanks!

Please Log in to join the conversation.

12 years 1 month ago #197958 by krileon
Replied by krileon on topic Re: Hide Content depending on CBsubs Plan
Includes only works if the returned value is an array and the query field returns a string rather then an array. You'd need to use REGEX to match the value


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Localization - CB Quickstart - CB Paid Subscriptions - Add-Ons - Forge
--
If you are a Professional, Developer, or CB Paid Subscriptions subscriber and have a support issue please always post in your respective support forums for best results!
--
If I've missed your support post with a delay of 3 days or greater and are a Professional, Developer, or CBSubs subscriber please send me a private message with your thread and will reply when possible!
--
Please note I am available Monday - Friday from 8:00 AM CST to 4:00 PM CST. I am away on weekends (Saturday and Sunday) and if I've missed your post on or before a weekend after business hours please wait for the next following business day (Monday) and will get to your issue as soon as possible, thank you.
--
My role here is to provide guidance and assistance. I cannot provide custom code for each custom requirement. Please do not inquire me about custom development.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.222 seconds

Facebook Twitter LinkedIn