-
-
Save gabrielmerovingi/15cf6d6a8898dc68a39340d3d6965a10 to your computer and use it in GitHub Desktop.
/** | |
* Enforce Maximum | |
* Make sure users can not earn more than 1000 points. | |
* @version 1.0 | |
*/ | |
function mycred_enforce_max_balance( $run, $request, $mycred ) { | |
extract( $request ); | |
// The maximum balance a user can have | |
$maximum = 1000; | |
// Get the users balance | |
$balance = $mycred->get_users_balance( $user_id ); | |
// Check if we already reached our max | |
if ( $balance >= $maximum ) return false; | |
// Next make sure this transaction will not bring us over the limit | |
$balance += $amount; | |
if ( $balance > $maximum ) return false; | |
// Below limit, please continue | |
return $run; | |
} | |
add_filter( 'mycred_add', 'mycred_enforce_max_balance', 1, 3 ); |
Secondly, how can I set the balance to the maximum if the mycred_add filters comes back false? Likewise, similar to the prevent negative balance gist you created, how can I set the balance to 0 regardless of the amount value requested? Thanks!
How can I set this post type and also how to can make it the max when a transaction higher is made.
Please help
@gabrielmerovingi i need help.
How can i restrict how many points a post or page can give out.
example: i create a post or page i want that post or page to award x number of points only or award x numbers or users on points for that particular post or page. once the target is meet, subsequent visit will will received a not receive points again for that post.
or
using the click on links.
a link can only award specific number of points using shortcode.
e.g i create a link, that link should give out only 500 points, once that link has given out 500 points, it shouldn't give out points again for subsequent clicks.
How can I specify a particular point type? I have 3 point types and only one of them should be capped. Thanks!