• 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!

TOPIC: Using a User Group to Auto Populate the To: Field

Using a User Group to Auto Populate the To: Field 11 years 3 months ago #26420

  • tewebmaster
  • tewebmaster's Avatar
  • OFFLINE
  • Fresh Boarder
  • Posts: 7
  • Thank you received: 1
You may want to do this is so you don't have to go back to each form and edit it whenever something changes (i.e. brotherhood mass e-mails, do you want to add/delete an e-mail each time someone joins/quits?).

The code you need is below:
//<code>
$db =& JFactory::getDBO();
$db->setQuery("SELECT email, name FROM #__users LEFT JOIN #__user_usergroup_map ON #__users.id=#__user_usergroup_map.user_id WHERE #__user_usergroup_map.group_id=27");
$results = $db->loadObjectList();
foreach ($results as $res){
	$value = $res->email;
	$label = $res->name;
	$items[] = $value;
}
return implode(" ",$items);
//</code>

You must create a new 'hidden field' on your form and place the code (with the code tags in the "Default value" section.

You need to change the number at the end of the 3rd line of the code to match that of your chosen user group. This can be found by going to Users >> Groups and looking at the id number on the right.

Once your field is created go to Properties >> Emails >> Admin Email and place the name of your hidden field in the To: box. The field entry should look like this:

{YourHiddenField:value}

In order to avoid getting a message telling you that you must insert at least one valid e-mail address, this should be placed in the administrator e-mail. If you wish to send an administrator an e-mail too, then use the "Admin Email" for that and the "additional Emails" for this code.

If this code doesn't seem to be working correctly, try typing it in long hand.

This code was based off of the one in this link on the RSJoomla! Forum: Topic: use joomla group as drop down menu
The administrator has disabled public write access.
  • 1

Read this first!

We do not monitor these forums. The forum is provided to exchange information and experience with other users ONLY. Forum responses are not guaranteed.

However, please submit a ticket if you have an active subscription and wish to receive support. Our ticketing system is the only way of getting in touch with RSJoomla! and receiving the official RSJoomla! Customer Support.

For more information, the Support Policy is located here.

Thank you!