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

mitchell’s picture

Status: Active » Postponed (maintainer needs more info)

What's your question?

mitchell’s picture

Version: 6.x-1.0-beta3 » 6.x-1.0
mitchell’s picture

Status: Postponed (maintainer needs more info) » Fixed

Marking as fixed due to inactivity.

francewhoa’s picture

@Alauddin: I wrote a tutorial at http://drupal.org/node/794280

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

mitchell’s picture

Component: Miscellaneous » Rules Core

Updated component.