【发布时间】:2015-03-11 08:17:35
【问题描述】:
所以我想做的是当用户按下提交按钮时,运行一个 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;
}
我想知道查询是否有效?如果它有什么问题,请务必提及更正。提前感谢您帮助/尝试帮助我。
【问题讨论】:
-
如果页面只是被重定向,返回值在哪里?
-
为什么不自己测试一下呢?这是简单的代码,不会花你很长时间来调试/找出。
-
使用返回值,返回余额扣除请求。是的,我错误地将其放置在重定向之后。
-
@Epodax 我是站点管理员而不是管理员,管理员要求我在大约一天后完成此问题并为他提供解决方案。
标签: php if-statement multipleoutputs