So what I wanna do is when a user pushes the submit button, a php query is run. In that php query if an "If statement" condition is fulfilled, I want to execute an operation (which in my case is a page redirection) and return false.
[EDIT] The whole query code is something like this:
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;
}
I wanna know if the query will work?? And if there's something wrong with it, please do mention the correction. Thanks in advance for helping / trying to help me.