Hi,
I have two questions that I cannot seem to find an answer for by searching the forum...
Q1) Which file (and please specify filepath) contains the last bit of code to indicate successful registration?
The reason is, is I have some code (see below) which I want to add. The code will POST information from the registration to my newsletter software (12All). For it to work it needs to be added to the last step of the workflow of registration.
Q2) The code below was created for VirtueMart, its added when a purchase is made (if the buyer's chooses to subscribe, the code will subscribe the user). Since the data extract is specific to the VirtueMart database - I was wondering if someone could give me a few pointers on how to extract info from Community Builder to;
a) create a custom field to ask a question
b) field names for "name", "email", etc
Any help appreciated
Regards
Michael
p.s. the code below is inserted at the bottom of checkout.thankyou.php in VirtueMart.
[code:1]
//
// 12All data link code - START -
// The code will transfer the current sale to 12All list "BeA!ert"
//
// uncomment next line when testing
//echo 'Start of 12All code for BeA!ert'.'<br />';
// Locate the record in "_orders" table that matches the current value in $order_id and copy this record into $query_orderinfo
$query_orderinfo = "SELECT * FROM #__{vm}_orders WHERE order_id='$order_id'";
// Extract the user id from the record stored in $query_orderinfo and copy this into $query_userid
$db->query( $query_orderinfo );
$query_userid = $db->f( 'user_id' );
// uncomment next line when testing
//echo '$query_userid variable = '.$query_userid.'<br />';
// Locate the record in "_user_info" table that matches the current value in $query_userid and copy this into $query_userinfo
$query_userinfo = "SELECT * FROM #__{vm}_user_info WHERE user_id='$query_userid'";
// Extract the relevant info from the record stored in $query_userinfo and copy this into $form_data array
$db->query( $query_userinfo );
// Check if customer wants to subscribe to mailing list
$join_bealert = $db->f( 'extra_field_4' );
// uncomment next line when testing
//echo '$join_bealert variable = '.$join_bealert.'<br />';
if ($join_bealert == 'Y') {
//Subscribe customer to BeA!lert mailing list
// uncomment next line when testing
//echo 'Start of subscribe'.'<br />';
// transfer data from $query_userinfo to $form_data (and include extra 12All info)
// "left" fields = 12All field names, "right" fields = VirtueMart fields from "_vm_user_info" table.
$form_data = array(
'email' => $db->f( 'user_email' ),
'name' => $db->f( 'first_name' ),
'field[1]' => $db->f( 'extra_field_3' ), // Field: How did you hear about us ?
'p' => '7', // default setting obtained from checking 12All subscriber form
'nlbox[1]' => '6', // default setting obtained from checking 12All subscriber form
'funcml' => 'add', // value required to subscribe to 12All mailing list
);
// Set URL of mailing list manager software
$form_url = 'http://localhost/mailmgr/box.php';
// Convert $form_data into format suitable for POST sending
foreach ($form_data as $name => $value){
if (strlen($request_data) > 0)
$request_data .= '&';
$request_data .= $name.'='.urlencode($value);
}
// Build the POST request
$url = parse_url($form_url);
$request = "POST ".$url["path"]." HTTP/1.1\r\n"."Host: ".$url["host"]."\r\n"."Content-type: application/x-www-form-urlencoded\r\n"."Content-length: ".strlen($request_data)."\r\n\r\n".$request_data;
// Open the connection
$fp = fsockopen($url, 80, $err_num, $err_msg, 30);
if ($fp){
// Submit form
fputs($fp, $request);
// Get the response
while (!feof($fp))
$response .= fgets($fp, 1024);
fclose($fp);
// echo $response;
} else {
echo 'Could not connect to: '.htmlentities($url).'<br />';
echo 'Error #'.$err_num.': '.$err_msg;
exit;
}
} else {
// Do not subscribe
// uncomment next line when testing
//echo 'Start of do not subscribe'.'<br />';
}
// uncomment next line when testing
//echo 'End of 12All code for BeA!ert'.'<br />';
//
// 12All data link code - END -
//
[/code:1]