user emails to form
5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 12, 2011 (RSS)
By Toledoh - August 10, 2011
I'm wanting to send an email to a few selected email address; like;
$to = "tim@domain.com.au,tim@another.com.au";
I want to create a list of comma separated emails based of the user table...
In the user table, I've got a checkbox "Notifications".
Im thinking something along the lines of;
for each $CURRENT_USER[notifications]
$email= $CURRENT_USER[email]
$emailList = $emailList + ,email
$email= ""
This way, in the email function I can have;
$to = "$emailList";
Tim (toledoh.com.au)
Re: [Toledoh] user emails to form
By Jason - August 11, 2011
What is stored in $CURRENT_USER['notifications']? Is it a multi-value check box list of emails?
Let me know and we'll try to come up with a solution for you.
Thanks,
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] user emails to form
By Toledoh - August 11, 2011
If that checkbox is ticked, it means that that user should be added to the email list.
If that's too easy :) I also have a list of projects (pulled from another table "projects" as value=num, label=title). We could use something like;
$listOptions = getListOptions('accounts', 'project');
$emailProject = "";
if (@$_REQUEST['project']) {
$emailProject = $listOptions[@$_REQUEST['project']];}
to identify the specific project being discussed, and then send emails ONLY to those users that have that project selected in their list of accessible projects.Tim (toledoh.com.au)
Re: [Toledoh] user emails to form
By Jason - August 12, 2011
So what you need is to select all users who have the notifications check box checked and are selected for the project selected in $_REQUEST['project'] and create a comma-separated list of those emails.
Is that right?
If so, you can use something like this:
$accounts = mysql_query_fetch_all_assoc("SELECT * FROM `{$TABLE_PREFIX}accounts` WHERE notifications = '1' AND project LIKE '%\t".intval(@$_REQUEST['project'])."\t%'");
$emailList = join(",", array_pluck($accounts, 'email'));
Hope this helps
Jason Sauchuk - Project Manager
interactivetools.com
Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/
Re: [Jason] user emails to form
By Toledoh - August 12, 2011
Thanks Jason!
Tim (toledoh.com.au)