0

Apologies for any confusion as I'm completely out of my depth here:

I've been trying to write a plugin which will send form data as XML to a CRM using SOAP. The basic plugin works fine, but I would like to make it more modular, allowing different users to add their own credentials to the sent data.

I've followed all the instructions to create an Admin settings page, the data is written into the WP database, now I would like to pass those variables into my message.

I've tried using:

    $options = get_option($this->option_name);

at the top of the page, then inside the message, inserting this:

    $xmlInputData='<?xml version="1.0" encoding="utf-8" ?><data><settings><origin="'.echo $my_options['origin'];.'" username="'.echo $my_options['user'];.'" password="'.echo $my_options['password'];.'" /></settings><enquiries><lead productName="Appointment Booking"><customer><name>'.$_REQUEST['first-name'].' '.$_REQUEST['last-name'].'</name><email>'.$_REQUEST['email'].'</email><postcode>'.$_REQUEST['postal'].'</postcode><houseNumber></houseNumber><address></address><city></city><region></region><tel>'.$_REQUEST['phone-number'].'</tel><mobile></mobile><notes></notes></customer></lead></enquiries></data>';

but the code is flagged as having syntax errors. I'm trying to escape the XML to insert the PHP but I don't have enough experience of this.

Can anyone help me to understand where I'm going wrong?

I've been tinkering with this for a while now but desperately need this to work soon.

Thanks in advance.

1 Answer 1

1

You don't need the echo when you are concatenating strings. Just remove it.

$xmlInputData='<?xml version="1.0" encoding="utf-8" ?><data><settings><origin="'. 
$my_options['origin'] .'" username="'. 
$my_options['user'] . '" password="'. 
$my_options['password'] . '" /></settings><enquiries><lead productName=\"Appointment Booking"><customer><name>'.
$_REQUEST['first-name'].' '.
$_REQUEST['last-name'].'</name><email>'.
$_REQUEST['email'].'</email><postcode>'.
$_REQUEST['postal'].'</postcode><houseNumber></houseNumber><address></address><city></city><region></region><tel>'.
$_REQUEST['phone-number'].'</tel><mobile></mobile><notes></notes></customer></lead></enquiries></data>';
2
  • Thanks @dalbaeb ;) Would you know if $options = get_option($this->option_name); is enough to retrieve from the Settings API? Commented Mar 21, 2014 at 15:25
  • Sure, though when you use get_option you're utilizing the Options API. Settings API is something else. Commented Mar 21, 2014 at 15:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.