user emails to form

5 posts by 2 authors in: Forums > CMS Builder
Last Post: August 12, 2011   (RSS)

By Toledoh - August 10, 2011

Hi Guys.

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";
Cheers,

Tim (toledoh.com.au)

Re: [Jason] user emails to form

By Toledoh - August 11, 2011

I thought the easiest thing would be to have a checkbox in the user table that is either Yes or No called "notifications"

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.
Cheers,

Tim (toledoh.com.au)

Re: [Toledoh] user emails to form

By Jason - August 12, 2011

Hi Tim,

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

WOW - perfect.

Thanks Jason!
Cheers,

Tim (toledoh.com.au)