Access across different CB sites

5 months 1 week ago #312923 by micheleq
Hi,
I have this situation, and though I have found a few ways to implement, I'd like to have the leanest way possible.
  • I have Old Site A, with paid membership (CB Subs) and now I've created a New Site B (also paid - CB Subs)
  • I am giving Site A members free access to Site B.
  • To do so, I've created a hidden free Plan ( called "Site A Member") on Site B. The only way to access this plan is via URL within Site A. So site A users see a button that says "signup for Site B for free".
  • To signup, they have to re-enter all their info as it a separate site, on a separate server. I request matching emails on both sites.
  • I manually approve those who sign up, so I keep tabs.

Now, I need to unsubscribe these members from Site B, if their memberships expire on Site A.

  • I have created a MySQL user that can query from site/server A to site/server B and vice versa.
One option I thought is creating a nightly cron job that would check all Site B members with a "Site A Member" plan, and check if on Site A they are enabled. This is more complicated than it looks, so I've been looking for alternatives.

I noticed there is a new CB CODE FIELD.

Could it be possible to set up a CB Code field on Site B, that would check if that user had an active membership on Site A? And then on login with Auto Actions check that field? If yes, then "Site A Member" plan set to active, and if no the plan is deactivated?

I'm thinking that this way there will be much less querying.

I can write the code for the CB Code field, but what would the Auto actions look like? Would I need 2, one to deactivate and one to activate as users come and go?

Or is there a simpler way that I haven't thought of?

Thank you,
Tomás
5 months 1 week ago #312934 by krileon

Could it be possible to set up a CB Code field on Site B, that would check if that user had an active membership on Site A? And then on login with Auto Actions check that field? If yes, then "Site A Member" plan set to active, and if no the plan is deactivated?

Recommend using CB Query Field for that. It can query external databases. So you'd basically query your other sites database to see if they've an active membership then yes CB Auto Actions can certainly cancel it or active it using a CB Paid Subscriptions action.

I can write the code for the CB Code field, but what would the Auto actions look like? Would I need 2, one to deactivate and one to activate as users come and go?

Yes, you'd need 2 auto actions to handle the different states.

Or is there a simpler way that I haven't thought of?

Only easier way I can think of is just migrate your users data over for them manually. Probably a matter of just moving _users, _comprofiler and the necessary usergroup mapping table if they've custom usergroups. This would avoid them having to register manually themselves.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
The following user(s) said Thank You: micheleq
5 months 5 days ago #313037 by micheleq
Hi Kyle,

So far so good, but I got stuck in a couple of places. ES Member is my subscription on Site B to reference Site A (ES) members.

First the CB Query field is working great. [cb_es_member] is the field.
I'm querying
SELECT block FROM #__users WHERE email = '[email]';
which returns either 0 (active user), 1 (inactive user) or NULL (no user found).

I have created 2 Auto Actions:
1- To Unsubscribe users who are no longer ES Members.
  • Type: CB Paid Subscriptions; Trigger: onAfterLogin;
  • Conditions: Field: Value; Custom Value: [cb_es_member](Format Functions); Operator: NOT EQUAL TO: 0;
  • Actions: Mode: Unsubscribe; Plans: ES Member;
  • Output: Display: Return; Layout: Please renew your membership in ES. ***(doesn't output any message)***

2- To Subscribe users who reactivated membership in ES.
  • Type: CB Paid Subscriptions; Trigger: onAfterLogin;
  • Conditions: Field: Value; Custom Value: [cb_es_member](Format Functions); Operator: EQUAL TO: 0;
  • Actions: Mode: Subscribe; Renew: Yes; Plans: ES Member;
  • Output: Display: Return; Layout: You've been re-subscribed

In the first Auto action, I get the output message: "Error Please login first" However, it does unsubscribe the user, so it will confuse users.

The Second Auto Action, does not work at all. I've tried changing parameters around but it does not subscribe them. I get the output message: "A membership is needed for access."

The "ES Member" Plan does not show in list of plans, only on URL. I've set it to lifetime for free. I've tried it being monthly and with "renew" and "subscribe", still no luck.

Any help would be appreciated.

Thank you,
Tomás
5 months 4 days ago #313047 by krileon

In the first Auto action, I get the output message: "Error Please login first" However, it does unsubscribe the user, so it will confuse users.

That just sounds like the user is trying to access a page they don't have access to.

The Second Auto Action, does not work at all. I've tried changing parameters around but it does not subscribe them. I get the output message: "A membership is needed for access."

Make your plan completely frontend accessible then retry your second auto action. It's possible it being URL accessible only could be blocking the subscribe from frontend even when it's done via API, but it shouldn't. You can also enable debug mode under Parameters of your auto action then enable debug mode and maximum error reporting in Joomla global configuration and retest to see if the auto action is failing.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
4 months 3 weeks ago #313232 by micheleq
Hi Kyle,

That just sounds like the user is trying to access a page they don't have access to.

Yes, it's the login, which the system just removed its subscription, so it will always be that case. I'd rather see the particular message for that action, but it's not too bad if it's overwritten by that, at least the subscription is getting expired as it should.

Make your plan completely frontend accessible then retry your second auto action. It's possible it being URL accessible only could be blocking the subscribe from frontend even when it's done via API, but it shouldn't. You can also enable debug mode under Parameters of your auto action then enable debug mode and maximum error reporting in Joomla global configuration and retest to see if the auto action is failing.

I've made the plan frontend, and also tried using other plans, but it didn't work.
I also put everything in debug mode and it seems that the "resubscribe" auto action is not getting activated. It doesn't show in the list at all. No errors either.

At this point I've tried all login triggers (before, after, success, fail, etc.) and none work. I'm out of options. I have not tried the 'reference variables' on the 'Parameters' tab, as I'm not certain what those would do.

Any pointers are appreciated,
Tomás
4 months 3 weeks ago #313241 by krileon
Only thing I can think of at this point is you're not using CB login. Are you sure you're using CBs login module/page? 3rd party login modules and Joomla login module do not trigger CB events.


Kyle (Krileon)
Community Builder Team Member
Before posting on forums: Read FAQ thoroughly + Read our Documentation + Search the forums
CB links: Documentation - Templates - CBSubs - Hosting - Forge - Incubator - GroupJive
--
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 EST to 4:00 PM EST. 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.
Moderators: beatnantkrileon
Time to create page: 0.433 seconds
Facebook Twitter Google LinkedIn