PaulMRivera
Forum Replies Created
-
You are a god. Works perfectly now. Thanks!
add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 ); function add_bonus_points_for_purchase( $reply, $request, $mycred ) { if ( $reply === false ) return $reply; // For Stripe Payments if ( $request['ref'] != 'buy_creds_with_stripe' ) { $amount = $request['amount']; // Award bonus for purchases over 9 points if ( $amount == 10 ) { // Give extra 2 points // Remember not to use $mycred->add_creds() here or you will // create an endless loop. Instead use update_users_balance() $mycred->update_users_balance( $request['user_id'], 2 ); // Log the good news $mycred->add_to_log( 'bonus_points', $request['user_id'], 2, 'Bonus points for %plural% purchase!' ); } } return $reply; }
I also tried this (switching “==9” to “> 9”:
add_filter( 'mycred_add', 'add_bonus_points_for_purchase', 10, 3 ); function add_bonus_points_for_purchase( $reply, $request, $mycred ) { if ( $reply === false ) return $reply; // For Stripe Payments if ( $request['ref'] != 'buy_creds_with_stripe' ) { $amount = $request['amount']; // Award bonus for purchases over 9 points if ( $amount > 9 ) { // Give extra 2 points // Remember not to use $mycred->add_creds() here or you will // create an endless loop. Instead use update_users_balance() $mycred->update_users_balance( $request['user_id'], 2 ); // Log the good news $mycred->add_to_log( 'bonus_points', $request['user_id'], 2, 'Bonus points for %plural% purchase!' ); } } return $reply; }
Yes I changed it to 9 instead of 100 to see if when i purchase 10, it will award 2.
Is there something I could add to the actual “mycred-stripe.php” in the stripe plugin folder that would award 2 credits to users if they purchase 10 credits, and award 5 credits to users if the purchase 20 credits since the code above isn’t working?
Thanks for the help.
I have not tried it with paypal because I do not have the account setup for that.
I have been trying to mess with the code and still nothing seems to work.
I have tried replacing that line of code already and it doesn’t appear to work. Any other suggestions?
Got it to work. Thanks for leading me to that file path.
Where can I find the form the myCRED creates?
No problem. Thanks for helping!
Figured it out. Switched the code to this and it worked:
<?php $user_id = get_current_user_id(); // all the reasons to deny access if ( ( function_exists( 'mycred_get_users_cred' ) && mycred_get_users_cred( $user_id ) == 0 && function_exists( 'pmpro_hasMembershipLevel' ) && pmpro_hasMembershipLevel( 'gold', $user_id ) ) ) : ?>
Thank you for your help!
Doesn’t appear to work with that code. Still blocks the “gold” membership from sending messages with 0 balance. I will keep trying, and let you know if I come up with anything.
It will work exactly how I need it to if there is a way for that code to bypass the excluded members.
Thanks again.
Worked great. I worked with you before to exclude a specific membership from mycred with the code.
/* Exclude gold from credits */ add_filter('bp_member_name','kleo_member_username'); add_filter( 'mycred_exclude_user', 'check_membership_exclusion', 10, 2 ); function check_membership_exclusion( $result, $user_id ) { // Make sure Paid Memberships Pro is installed if ( ! function_exists( 'pmpro_hasMembershipLevel' ) ) return $result; // If the user has membership "gold exclude if ( pmpro_hasMembershipLevel( 'gold', $user_id ) ) return true; return $result; }
The code you posted above also blocks even the excluded membership. Is there a way to allow the excluded membership to message with a 0 balance?
Thank you
I found this on one of your example pages:
// Example $user_id = get_current_user_id(); $balance = mycred_get_users_cred( $user_id ); if ( $balance > 0 ) { // balance is over zero show the form } else { // balance is lower then zero show something else }
Would I use this? I am trying to input this by putting the <form></form> in the “show form” section but can’t seem to get it right
Would I wrap the entire compose.php with mycred_get_users_cred? I’m not great at code so not exactly sure how to wrap it.
And is there a way to show a message when they have a 0 balance when the form is not shown?
Thanks