Skip to Content Skip to Menu

🌟 CB Editor Assistant 1.0.0 is here! Discover our new AI Joomla Plugin that wrote its story! (and this banner!)
Start at just $12.50/month* or 💸 save 30% with our 🛍️ Intro Black Friday Offer for a lifetime*

[SOLVED] Best method to change Joomla User Group when a Select Field is saved?

  • ThePiston
  • ThePiston
  • OFFLINE
  • Posts: 334
  • Thanks: 26
  • Karma: 1
6 years 5 months ago - 6 years 5 months ago #305558 by ThePiston
I've got a Select Field with options and when one is selected I need to not only change a user group but delete one as well first.

These are the options in the CB select field:
Code:
{ Northern Southern Eastern Western }

I will need to run this query when the Profile is saved in order to delete the current User Group in question (only 4 options represented by 23,24,33,34)
Code:
DELETE IGNORE FROM `#__user_usergroup_map` WHERE `#__user_usergroup_map`.`user_id` = [USER_ID] AND `#__user_usergroup_map`.`group_id` IN (23,24,33,34)

and also run this query afterwards, but I need to set the CB field options = to actual user group values somehow like this:
Code:
data= { northern: 003; western: 004; eastern: 005; western: 006; }
Code:
INSERT IGNORE INTO `jos_user_usergroup_map` (`user_id`, `group_id`) VALUES ('[USER_ID]', 'OPTION_SELECTED');

Would this be something the CB Query field can do or maybe CB Auto Actions?

Thank you

CB 2.3, CBsubs 4.3, PHP 7.1, J! 3.9.X
Last edit: 6 years 5 months ago by krileon. Reason: Added [SOLVED] tag to subject

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48556
  • Thanks: 8292
  • Karma: 1445
6 years 5 months ago #305588 by krileon
You can do that using CB Auto Actions. Check out the tutorial below to get started.

www.joomlapolis.com/documentation/291-cb-auto-actions/tutorials/18237-cb-auto-actions-assigning-usergroup-based-on-cb-field-value

CB Auto Actions can Add, Remove, Replace, and even Create usergroups using its Usergroup action.


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.
The following user(s) said Thank You: ThePiston

Please Log in or Create an account to join the conversation.

  • ThePiston
  • ThePiston
  • OFFLINE
  • Posts: 334
  • Thanks: 26
  • Karma: 1
5 years 6 months ago #312382 by ThePiston
that sounds easier. If I want to allow multiple actions based on a multi-select field, would I need to add one AA per choice or can it all be done in one AA? From what I am reading, it looks like I have to create an AA for each choice in the multi-select field, correct?

Choice 1 -> Assign Joomla Group 1
Choice 2 -> Assign Joomla Group 2
Choice 3 -> Assign Joomla Group 3
Choice 4 -> Assign Joomla Group 4
Choice 5 -> Assign Joomla Group 5
Choice 6 -> Assign Joomla Group 6
Choice 7 -> Assign Joomla Group 7
Choice 8 -> Assign Joomla Group 8
Choice 9 -> Assign Joomla Group 9
Choice 10 -> Assign Joomla Group 1
Choice 11 -> Assign Joomla Group 11

CB 2.3, CBsubs 4.3, PHP 7.1, J! 3.9.X

Please Log in or Create an account to join the conversation.

  • krileon
  • krileon
  • ONLINE
  • Posts: 48556
  • Thanks: 8292
  • Karma: 1445
5 years 6 months ago #312392 by krileon

that sounds easier. If I want to allow multiple actions based on a multi-select field, would I need to add one AA per choice or can it all be done in one AA? From what I am reading, it looks like I have to create an AA for each choice in the multi-select field, correct?

You would need an auto action per choice, which is perfectly fine to do.


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 or Create an account to join the conversation.

Moderators: beatnantkrileon
Powered by Kunena Forum