Hi,

I have created a custom profile checkbox on registration asking the user if they want to subscribe to the newsletter. The newsletter is through a 3rd-party site.

I need the registration form to send a confirmation email to the newsletter email address, but only IF they have checked the box.

So, if the box is checked, then an email TO the newsletter system must be sent FROM the registrant...

any ideas?

Ron

Comments

rlnorthcutt’s picture

This is not quite as elegant a solution as I hoped, but it works. Basically, I just created a simple PHP form to send an email IF the checkbox was checked. I then placed this code in the user.module as the new user is created. It seems to work fine. Here is the code if anyone wants it - or if anyone can suggest a better way:

   // Build the finished user object.
    $user = user_load(array('uid' => $array['uid']));    
  }  
/***   CUSTOM CODE START   ***/
  // Check and subscribe to newsletter if applied  
  if ($user->profile_CheckBoxName == 1) {
     $regEmail = $user->mail;
     $regName = $user->profile_FullNameField;
     $to      = 'email@direct-response-auto-responder.com';
     $subject = 'subscribe';
     $message = 'subscribe';
     $headers = 'From: '.$regName.'<'.$regEmail.'>'."\r\n".'Reply-To: '.$regEmail."\r\n".'X-Mailer: PHP/' . phpversion();  
     mail($to, $subject, $message, $headers);
     }
/***   CUSTOM CODE END   ***/
  // Save distributed authentication mappings

The custom bit inserts on line 241 - the clip above includes lines 237-254 with the code inserted. These items will be dependent on your form and the direct subscribe email:
- profile_CheckBoxName
- profile_FullNameField
- email@direct-response-auto-responder.com

This was for an auto-responder hosted with 1ShoppingCart.

Ron

regards,
Ron Northcutt
Directory of Technical Marketing, Acquia

clkeenan’s picture

Looks like promising code!