[SOLVED] Assign User to Juga Group

13 years 9 months ago #135523 by GoremanX
[SOLVED] Assign User to Juga Group was created by GoremanX
I want to use CBSubs to assign a user to a specific JUGA group when he/she subscribes to a specific plan. The table I need to modify is #__juga_u2g and all I need to do is add the member's userid and the id of the group he/she is being assigned to, along with a created date/time. So the table looks like this:

[code:1]user_id group_id created_datetime
99 4 2010-05-12 00:58:22
100 1 2010-05-13 00:58:22
99 1 2010-05-15 00:58:22
101 3 2010-05-18 00:58:22[/code:1]

(user_id 99 belongs to two groups)

Say I wanted to add a row that assigns a user_id to a group_id when a member subscribes, and remove that row when he/she unsubscribes. How would I enter that in the SQL actions tab?

Thanks!

Post edited by: krileon, at: 2010/06/16 19:07

Please Log in to join the conversation.

13 years 9 months ago #135535 by GoremanX
Replied by GoremanX on topic Re:Assign User to Juga Group
This is my wild-ass guess, assuming I wanted to add the user to group_id 4:

[code:1]INSERT INTO #__juga_u2g VALUES([user_id],4,NOW());[/code:1]

However:

- is that the proper use of [user_id]?

- can I use the #__ table prefix? Or do I need the real prefix?

And if I wanted to remove the user from that group, I assume this would be the appropriate way to do it:

[code:1]DELETE FROM #__juga_u2g WHERE user_id = [user_id] AND group_id = 4 LIMIT 1;[/code:1]

Please Log in to join the conversation.

13 years 9 months ago #135564 by krileon
Replied by krileon on topic Re:Assign User to Juga Group
Sorry, don't know Jugas database structure but your queries look a bit off. Please see following examples (I don't know table names so adjust as necessary!).

[code:1]
INSERT INTO `#__juga_u2g` ( `user_id`, `group`, `date` ) VALUES ( [user_id], 4, NOW() );
[/code:1]
You should always specify the columns just to be safe. If an additional column was added and you did not specify columns it would completely offset your inserts or cause them to fail entirely. Also notice the "quotes" around tables and columns.

- is that the proper use of [user_id]?

Yes

- can I use the #__ table prefix? Or do I need the real prefix?

Yes

[code:1]
DELETE FROM `#__juga_u2g` WHERE `user_id` = [user_id] AND `group_id` = 4;
[/code:1]
Limit generally doesn't work on delete queries and will just error. Either further clarify your delete WHERE statement or let it delete everything from that user.

Post edited by: krileon, at: 2010/06/14 14:54


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.

13 years 9 months ago #135661 by GoremanX
Replied by GoremanX on topic Re:Assign User to Juga Group
That works perfectly, thank you!

By combining JUGA groups, MetaMod Pro and CBSubs, I was finally able to control the display of modules on a page. So now I can offer ad-removal subscriptions where the ad banners don't get displayed to subscribers, and the ad modules don't take up any space on the page when they're not being displayed. It was a convoluted setup, but it seems to work well.

Please Log in to join the conversation.

Moderators: beatnantkrileon
Time to create page: 0.204 seconds

Facebook Twitter LinkedIn