我有此功能,我想检查$ item_field是否等于url参数要做某件事,但是我不知道如何在功能中使用此变量。<<<<<</p>
function update_buynow_on_cancellation($entry_id, $form_id) {
//update policy transaction type when entry on cancellation
if ($form_id == 12) {
$item_field = $_POST['item_meta'][366]; // get the value of item_meta
$to = 'stanislav@goliveuk.com';
$subject = 'Cancellation';
$headers = 'MIME-Version: 1.0'. "rn";
$headers.= 'Content-type: text/html; charset=iso-8859-1'. "rn";
$message = '<a href="caravan.dev.golivesolutions.co.uk?accept='.$item_field.'">Accept</a><br><a href="caravan.dev.golivesolutions.co.uk?decline">Decline</a>';
wp_mail($to, $subject, $message, $headers);
}
}
$accept = $_GET['accept'];
if ($accept = $item_field) {
global $wpdb, $frmdb;
$wpdb -> update($wpdb -> prefix.'frm_item_metas', array('meta_value' => 'CX'), array('item_id' => $item_field, 'field_id' => '435'));
$new_entry_id = FrmEntry:: duplicate($item_field);
$wpdb -> update($wpdb -> prefix.'frm_item_metas', array('meta_value' => 'CX'), array('item_id' => $item_field, 'field_id' => '390'));
} else {
//do something
}
有什么想法吗?
尝试在全球范围内使用,以便您可以访问变量外部功能
function update_buynow_on_cancellation($entry_id, $form_id)
{
//update policy transaction type when entry on cancellation
if ($form_id == 12 ) {
$GLOBALS['item_field'] = $_POST['item_meta'][366]; //here i made it as GLOBAL variable
$to = 'stanislav@goliveuk.com';
$subject = 'Cancellation';
$headers = 'MIME-Version: 1.0' . "rn";
$headers .= 'Content-type: text/html; charset=iso-8859-1' . "rn";
$message ='<a href="caravan.dev.golivesolutions.co.uk?accept='.$item_field.'">Accept</a><br><a href="caravan.dev.golivesolutions.co.uk?decline">Decline</a>';
wp_mail($to, $subject, $message, $headers);
}
}
$accept = $_GET['accept'];
if($accept = $item_field){
global $wpdb, $frmdb;
$wpdb->update($wpdb->prefix.'frm_item_metas', array('meta_value' => 'CX'), array('item_id' => $item_field, 'field_id' => '435'));
$new_entry_id = FrmEntry::duplicate( $item_field );
$wpdb->update($wpdb->prefix.'frm_item_metas', array('meta_value' => 'CX'), array('item_id' => $item_field, 'field_id' => '390'));
}else{
//do something
}