Created
December 1, 2014 11:12
-
-
Save gabrielmerovingi/126484a9bdbe3a7e5d91 to your computer and use it in GitHub Desktop.
Enforces a minimum 50 point transfer requirement when using the mycred_transfer shortcode.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Minimum Transfer Requirement | |
* Force users to transfer a minimum amount of points | |
* when using the mycred_transfer shortcode. | |
* @version 1.0 | |
*/ | |
add_action( 'mycred_transfer_ready', 'mycred_min_transfer_req', 10, 2 ); | |
function mycred_min_transfer_req( $transaction_id, $post ) { | |
// Get amount | |
$amount = abs( $post['mycred-transfer-amount'] ); | |
// Example: Minimum 50 points | |
if ( $amount < 50 ) | |
die( json_encode( 'low_amount' ) ); | |
} | |
/** | |
* Add Custom Transfer Message | |
* Add a custom transfer message when a user transfers | |
* to low amount. | |
* @version 1.0 | |
*/ | |
add_filter( 'mycred_transfer_messages', 'mycred_pro_custom_transfer_messages' ); | |
function mycred_pro_custom_transfer_messages( $messages ) { | |
$messages['low_amount'] = 'You must transfer minimum 10 points.'; | |
return $messages; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment