我正在尝试注册自定义路由,以验证登录页的groupon凭单代码。我在函数中注册了路由。php类似:
// Adding Custom Voucher Route
add_action(\'rest_api_init\',\'register_voucher_endpoint\');
function register_voucher_endpoint() {
register_rest_route(
\'voucher\',
\'verify/(?<voucher_code>)\',
array(
\'methods\'=> \'POST\',
\'callback\'=>\'verify_voucher\'
));
}
function verify_voucher($request) {
return $request[\'voucher_code\'];
}
我在表单操作上设置了如下链接<form action="/voucher/verify" method="POST">
<h5 class="title">Please enter your 8-character Groupon Voucher Code to redeem your
purchase</h5>
<p>Note: You will have a voucher code for each product you buy on Groupon. For example,
if you bought 2 CBD sprays on Groupon, you\'ll have to enter 2 voucher codes, one
for each spray.</p>
<input required="" class="branded-input margin-bottom" type="text"
minlength="8" maxlength="8" title="voucher-code" name="voucher-code" placeholder="Enter your 8 Character Groupon code">
<input type="submit" value="Redeem My CBD!" class="btn btn-color-primary btn-style-bordered btn-size-large">
当我单击提交按钮或手动转到注册的路由时,它会重定向到主页,网络选项卡显示“验证”路由返回301。站点正在使用重定向,但没有任何选项包括我注册的自定义路由。两个主要问题:
为什么会发生这种重定向