Skip to Content Skip to Menu

Profile Dropdown Showing Userlist From Specific Group

  • mhs_cb
  • mhs_cb
  • OFFLINE
  • Posts: 53
  • Thanks: 0
  • Karma: 0
10 years 1 month ago #248768 by mhs_cb
I need to create a user relationship between users using a dropdown list on user profiles.

In my company I have client users, and staff users. I need to assign a dedicated customer service rep to each client user. My solution was to create a dropdown list on the users profile that lists all staff members (from the staff member ACL group) and be able to select their customer service rep from there. Is this possible? This also needs to be searchable so that the rep can list any client that is assigned to them on the user list page.

If it's not possible, is there a different way to do this? Suggestions/solutions?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8283
  • Karma: 1443
10 years 1 month ago #248785 by krileon
You can use CB Query Field and its Query Select fieldtype. This will allow you to generate a single-select fieldtype with its options pulled from a database query. You could create a query that queries for all the users with your staff usergroup. Example as follows pulls all Registered users, alter as needed.

Query:
Code:
SELECT DISTINCT g.`user_id`, u.`username` FROM `#__user_usergroup_map` AS g LEFT JOIN `#__users` AS u ON u.`id` = g.`user_id` WHERE g.`group_id` = 2
Value Column: user_id
Label Column: username


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.

  • mhs_cb
  • mhs_cb
  • OFFLINE
  • Posts: 53
  • Thanks: 0
  • Karma: 0
10 years 1 month ago #248793 by mhs_cb
Should the example work as is mentioned above?

I get the following error on "Edit My Profile" once the field is published:
_____________
1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '`joom3_user_usergroup_map` AS grnLEFT JOIN `joom3_users` AS urnON u.`id` = g.`us' at line 1 SQL=SELECT DISTINCT g.`user_id`, u.`username`rnFROM `joom3_user_usergroup_map` AS grnLEFT JOIN `joom3_users` AS urnON u.`id` = g.`user_id`rnWHERE g.`group_id` = 2
______________

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

  • mhs_cb
  • mhs_cb
  • OFFLINE
  • Posts: 53
  • Thanks: 0
  • Karma: 0
10 years 1 month ago #248842 by mhs_cb
Sorry, my bad. It was just bad formatting.

I see a dropdown now, but nothing in it.

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

  • mhs_cb
  • mhs_cb
  • OFFLINE
  • Posts: 53
  • Thanks: 0
  • Karma: 0
10 years 1 month ago #248844 by mhs_cb
I changed the group ID and certain groups work (and show users within), but other groups don't. Strange.

Oh, I guess the users need to be directly within that group? Can't select a parent group?

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

  • krileon
  • krileon
  • ONLINE
  • Posts: 48479
  • Thanks: 8283
  • Karma: 1443
10 years 1 month ago #248860 by krileon
It's only grabbing the users with the specific group id. So they have to have that usergroup. You can use an IN statement for multiple usergroups or whatever you like. Please note it's using usergroups and not view access levels. The provided example should give a list of every user with the Registered usergroup (ID of 2).


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