所以我想做的是当用户按下提交按钮时,运行一个 php 查询。在那个 php 查询中,如果满足“If 语句”条件,我想执行一个操作(在我的例子中是页面重定向)并返回 false。
[编辑] 整个查询代码是这样的:
add_filter( ‘mycred_add’, ‘mycred_pro_restrict_negative_balances’, 1, 3 );
function mycred_pro_restrict_negative_balances( $reply, $request, $mycred ) {
if ( $reply === false || $request[‘amount’] > 0 ) return $reply;
extract( $request );
// Users current balance
$current_balance = $mycred->get_users_balance( $user_id, $type );
// If balance is zero – decline OR If we are deducting points, make sure the amount will not take us below zero
if (( $current_balance <= 0 )||(($current_balance – abs( $amount )) < 0 )) {
$redirect_to_page = 22;
return false;
}
return $reply;
}
我想知道查询是否有效?如果它有什么问题,请务必提及更正。提前感谢您帮助/试图帮助我。