我有一个名为wc-info.php的页面,该页面使用此函数加载在名为plugin_admin.php的页面上
public function iris_info()
{
include('partials/wc-info.php');
}
public function get_gtin_woo_db($GTIN_Val)) {
// get the gtin number
$key = 'sku';
$getTheMeta = get_post_meta($GTIN_Val, $key, TRUE);
if ($getTheMeta != '') {
$gtinSuccess = 'Yes';
} else {
$gtinSuccess = 'No';
}
return $gtinSuccess;
}
部分看起来像这样:
<div class="welcome-panel-column">
<form action="POST">
<input type="text" action="" name="gtin_search">
<input type="submit" action="" name="gtin_submit">
</form>
</div
问题是如何将POST值传递到wordpress中的plugin_admin.php页面?当点击提交时,我需要重新加载页面,并将POST传递给函数。
试试这个,
function custom_function() {
if ( isset( $_POST['gtin_search'] ) ) {
// Update to the function which you are going to use
get_gtin_woo_db($POST['gtin_search']);
} // end if
}
add_action( 'init', 'custom_function' );
我希望这会有所帮助。