Created
September 14, 2017 14:27
-
-
Save gabrielmerovingi/e4c1da23f2b0c11de7d75100609262b3 to your computer and use it in GitHub Desktop.
Charge a custom fee based on a users WordPress role when making a transfer in myCRED.
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
/** | |
* Custom transfer Fees | |
* Charge a custom fee based on a users WordPress role when making | |
* a transfer in myCRED. | |
* @version 1.0 | |
*/ | |
function mycred_pro_transfer_fee_by_role( $fee, $amount, $user_id, $point_type, $prefs ) { | |
// if we are just a subscriber, impose 10% fee | |
if ( ! user_can( $user_id, 'publish_posts' ) ) | |
$fee = $amount * 0.1; | |
// else if we are an "contributor", impose 5% fee | |
elseif ( ! user_can( $user_id, 'delete_published_posts' ) ) | |
$fee = $amount * 0.05; | |
// everyone else pays no fee | |
else $fee = 0; | |
return $fee; | |
} | |
add_filter( 'mycred_pt_get_fee', 'mycred_pro_transfer_fee_by_role', 10, 5 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment