有人可以帮助我并告诉我在点击此按钮时我可以在哪里调用我的xml代码。谢谢大家的答复。附件是我的xml代码和按钮的代码。
<p class="woocomerce-FormRow form-row">
<?php wp_nonce_field('woocommerce-register', 'woocommerce-register-nonce'); ?>
<input type="submit" class="woocommerce-Button button" name="register" value="<?php esc_attr_e('Register', 'woocommerce'); ?>" />
</p>
<?php
//rest/customers
$xml = "<customer><activation-code>" . rand(100000, 999999) . "</activation-code>
<area-code-id type=\"integer\"></area-code-id>
<billing-failure-date type=\"datetime\" nil=\"true\"/>
<created-at type=\"datetime\"></created-at>
<email>" . $current_user->user_email . "</email>
<first-name>" . $resultVorname->value . "</first-name>
<id type=\"integer\"></id>
<language-id type=\"integer\">2</language-id>
<last-name>" . $resultNachname->value . "</last-name>
<npvr-limit type=\"integer\" nil=\"true\"/>
<npvr-quota type=\"integer\">360000</npvr-quota>
<other-than-stb-devices-limit type=\"integer\">1</other-than-stb-devices-limit>
<phone>" . $resultTelefon->value . "</phone>
<pin>" . rand(1000, 9999) . "</pin>
<pvr-limit>NO_LIMIT</pvr-limit>
<secondary-pin>" . rand(1000, 9999) . "</secondary-pin>
<status>enabled</status>
<stb-devices-limit type=\"integer\">1</stb-devices-limit>
<updated-at type=\"datetime\"></updated-at>
<uuid></uuid>
<external-id nil=\"true\"/>
<npvr-quota-used type=\"integer\">1</npvr-quota-used>
<npvr-limit-used type=\"integer\">1</npvr-limit-used>
<area-code-external-id nil=\"true\"/>
<language-external-id nil=\"true\"/>
<address-attributes>
<city>" . $resultOrt->value . "</city>
<street>" . $resultStrasse->value . "</street>
<postal-code>" . $resultPostleitzahl->value . "</postal-code>
<province-id>119</province-id>
</address-attributes>
</customer>";
$url = 'https://xxx.xxx.xx.xx:xxxx/rest/customers';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml', 'Authorization: Basic QTFDVjVsaGl5d1d2NXh3UWJ0OFE6'));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$data = curl_exec($ch);
//print $data;
//var_dump($data);
$xml = simplexml_load_string($data);
$json = json_encode($xml);
$arr = json_decode($json, true);
//print_r($arr['id']);
if (curl_errno($ch))
print curl_error($ch);
else
curl_close($ch);
?>
代码应该在注册按钮上单击时执行,所以我想立即将这个xml发送到服务器。
这是从整个动作中我注意到这个按钮被调用..
<?php do_action( 'woocommerce_register_form' ); ?>
<p class="woocomerce-FormRow form-row">
<?php wp_nonce_field( 'woocommerce-register', 'woocommerce-register-nonce' ); ?>
<input type="submit" class="woocommerce-Button button" name="register" value="<?php esc_attr_e( 'Register', 'woocommerce' ); ?>"/>
</p>
<?php
&#13;