Closed (fixed)
Project:
Rules
Version:
6.x-1.0
Component:
Rules Core
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
27 Nov 2008 at 11:56 UTC
Updated:
26 May 2012 at 17:34 UTC
Hello
I would like to try to execute my autoresponder form when trigger for action = user account is created.
here is the custom php code below.
Only variable that is needed is the 'email address' of the new durpal user passed on in the form as $emailAddress
// ----- Change this to your IEM installation URL and form ID
define('CONST_IEM_URL', 'http://localhost/iem');
define('CONST_IEM_FORMID', '1');
// -----
// Defines header to be text/json
header('Content-Type', 'text/x-json');
// Receive the $_POST
$emailAddress = isset($_POST['txtEmail'])? trim($_POST['txtEmail']) : '';
if($emailAddress == '') {
print json_encode(array('status' => false, 'message' => 'Email cannot be empty'));
exit();
}
// Set up the variable that needed to be sent over to IEM
$variables = array(
'format' => 'h',
'email' => $emailAddress
);
// Set up the URL (including the form id
$url = CONST_IEM_URL . '/form.php?form=' . CONST_IEM_FORMID;
// ----- Send Request to IEM
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $variables);
$response = @curl_exec($ch);
curl_close($ch);
if($response === false) {
print json_encode(array('status' => false, 'message' => 'Cannot query IEM'));
exit();
}
// Do some other checking stuff to determine
// whether or not email has been subscribed correctly
// -----
// Return a success
print json_encode(array('status' => true, 'message' => 'Your email has been subscribed to our mailing list'));
Thanks in advance for the help.
Comments
Comment #1
mitchell commentedWhat's your question?
Comment #2
mitchell commentedComment #3
mitchell commentedMarking as fixed due to inactivity.
Comment #4
francewhoa@Alauddin: I wrote a tutorial at http://drupal.org/node/794280
Comment #6
mitchell commentedUpdated component.