Hello, I'm using drupal 5.20. I'm creating a module so when a user submits their registration, the information is passed on to our email company, and then the user is redirected to a thank you page. I want this to occur after the form has been submitted hence I'm trying to test if there are form values first. Could someone please be of assitance in deciphering what I've got wrong. Below is one way I've tried, and below that is another idea I've tried. Thank you very much!!

function registrationredirect_form_alter($form_id, &$form) {
    if($form_id == 'user_register' && $form['values']) {
        	        $name = $form['profile_name'];
			$mail = $from['mail'];
			
			$Curl_Session = curl_init('http://createsend.com/t/y/s/dulkhy/');
			curl_setopt ($Curl_Session, CURLOPT_POST, 1);
			curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "cm-name=$name&cm-dulkhy-dulkhy=$mail&cm-f-julydr=1");
			curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
			curl_exec ($Curl_Session);
			curl_close ($Curl_Session);
			
			$form['#redirect'] = 'node/159';
		
    }
}

the second idea i've tried is below:

function registrationredirect_form_alter($form_id, &$form) {
    if($form_id == 'user_register') {
        $form['#submit'] = 'registrationredirect_form_submit';
		$form['#redirect'] = 'node/159';
    }
}


function registrationredirect_form_submit($form_id, &$form) {

			$name = $form['profile_name'];
			$mail = $edit['mail'];
			
			$Curl_Session = curl_init('http://createsend.com/t/y/s/dulkhy/');
			curl_setopt ($Curl_Session, CURLOPT_POST, 1);
			curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "cm-name=$name&cm-dulkhy-dulkhy=$mail&cm-f-julydr=1");
			curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1);
			curl_exec ($Curl_Session);
			curl_close ($Curl_Session);

}

Comments

RyanFC’s picture

I've got it working now. I doubt its the best way but it works! ..if anyone has any comments please post them, otherwise, here's my solution.

function registrationredirect_form_alter($form_id, &$form, $form_state) {
    if($form_id == 'user_register') {
		if($_POST['mail'] && $_POST['profile_name']) {
			$mail = $_POST['mail'];
			$name = $_POST['profile_name'];
			....my curl code here....
	
		}
	$form['#redirect'] = 'node/159';
    }
}