The WordPress Stackexchange said my post was off topic because it was a php syntax question and not a WordPress question so I'm posting here hoping for help.
After countless test runs to overcome fatal parse errors, I now have an error free php file, but it does nothing. The array values are not being passed correctly in an xml string the server will accept and I can't see any errors that tell me anything.
This file was originally written to run on an html website and for all of the array's fields to be manually entered into one array to test the connection and processing of the xml string.
The first six values of the array are known values that never change and can be hard coded, but the last 10 values are always different and must be queried to create the array.
I need to either pass data from two arrays into one single xml string, or somehow code one array that does the work.
I'm the first guy who is adapting this code to work in a WordPress environment. The mepr- fields are custom usermeta fields I need from the WordPress DB. All this file does is pass user registration information so the partner website has all of the same information the first site does, so a user doesn't have to signup twice for both sites.
This is my code which currently doesn't work, and doesn't report errors:
error_reporting(E_ERROR);
ini_set(‘display_errors’,true);
// Set the Query POST parameters
$query_vals = array(
'api_username' => 'set-value-username',
'api_password' => 'set-value-password',
'api_key' => 'set-value-api-key',
'perkalert' => 0,
'offer_radius' => 20,
'send_welcome_email' => 1
);
// Insert pluggable.php before calling get_currentuserinfo()
require (ABSPATH . WPINC . '/pluggable.php');
// Get new WordPress user registration information
global $current_user;
get_currentuserinfo();
// Values in this array are variables
$query_vals == array(
'firstname: ' . $current_user==> 'user_firstname',
'lastname: ' . $current_user==> 'user_lastname',
'adress: ' . $current_user==> 'mepr-address-one',
'city: ' . $current_user==> 'mepr-address-city',
'state: ' . $current_user==> 'mepr-address-state',
'zip: ' . $current_user==> 'mepr-address-zip',
'country: ' . $current_user==> 'mepr-address-country',
'email: ' . $current_user==> 'user_email',
'username: ' . $current_user==> 'user_login',
'password: ' . $current_user==> 'user_pass'
);
// Generate the POST string
$postdata = '';
foreach($query_vals as $key => $value) {
$postdata .= $key.'='.urlencode($value).'&';
}
// Chop of the trailing ampersand
$postdata = rtrim($postdata, '&');
// create a new cURL resource
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://third-party-site.com/register_member.xml');
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postdata);
// Save response to a string
$response = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($response);
if ($xml === false) {
die('Error parsing XML');
}
//var_dump($xml);
echo "Status: ".$xml->status;
The main focus is the two arrays and how to pass the data. If I get errors getting the WordPress user data, I'll take that up with the WordPress Stackexchange.
Any help here is greatly appreciated.