MySQL Query Help - Edit User's ACL Based on CB

12 years 5 months ago #181151 by Hotties Wrestle
MySQL Query Help - Edit User's ACL Based on CB was created by Hotties Wrestle
This might be out of the scope of the forum, but I figured I would ask.

I want to do a mass update of users in the database, based on a CB field. Something like:

User has CB field: Gender = Female
ACL group (via artofuser) Girls (id = 33).

I want to find users with the gender of female and change their ACL group from registered (18) to girls (33). What would be the query I write for that? I know I'm looking at stuff that's in at least two different tables.

Please Log in to join the conversation.

12 years 5 months ago #181196 by krileon
CB Fields can't do that, you would need CB Queries. ACL is very complex, changing it via a query is a terrible idea. Especially in J1.7 where it is heavily cached into API and Session so changing it via query would have zero immediate effect for the user. At any rate the below will do it (J1.7, you provided no version), test extremely thoroughly.
UPDATE `#__users` SET `usertype` = 'Girls' WHERE `id` = [user_id]
REPLACE INTO `#__user_usergroup_map` ( `user_id`, `group_id` ) VALUES ( [user_id], 33 )
DELETE FROM `#__user_usergroup_map` WHERE `user_id` = [user_id] AND `group_id` != 33

With the above it'll set the usertype, add or replace (if it already exists) the girls usergroup, then remove all usergroups except the girls usergroup (optional on J1.7 if you want multi-usergroups).


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 5 months ago #181269 by Hotties Wrestle
Replied by Hotties Wrestle on topic Re: MySQL Query Help - Edit User's ACL Based on CB
My apologies, it's J1.5 and CB1.7, and the extra groups are made by ArtofUser.

The idea is to use MetaMod to show modules on a page to certain viewer's user groups. If ACL is too tricky, could I get the viewer's group variable from GroupJive? (they are already in a GJ group).

Please Log in to join the conversation.

12 years 5 months ago - 12 years 5 months ago #181317 by krileon
J1.5 doesn't support custom usergroups nor does CB support said custom usergroups on J1.5. I suggest upgrading to J1.7. I can't suggest an ACL query on J1.5 that is not supported, sorry. You'll need to review database and construct one your self.

GroupJive has nothing to do with ACL so no it could not help in that regard. GroupJive provides groups as in how Facebook, MySpace, or any other social site has groups. You can of course alter a users GJ attendance (create category, create group, join group) automatically for example using the Auto integration included with the GJ package. It can also be done through CBSubs GJ integration or through incubator Auto Actions project.


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.182 seconds

Facebook Twitter LinkedIn