-
Author
-
September 19, 2017 at 22:44 #174157psmorrowParticipant
Hi,
I’m working with the Mycred plugin with the Transfer addon, and having some issues with hooking into a mycred action. I understand if you can’t help, but the mycred support doesn’t appear to be very responsive.
I’m trying to award a specific user points/credits each time one user transfers credits to another user. The function I want to hook into is: mycred_transfer_completed.
Here is my snippet from bp-custom.php:
add_action( ‘mycred_transfer_completed’, ‘add_points_for_referral’, 10, 2 );
function add_points_for_referral( $transfer_id, $request ) {
extract ($request);
$transfer_amt = $request[‘amount’];
mycred_add( ‘Transfer Bonus’, 3, 5, $transfer_amt);
return;
}
As far as I can tell, the variable $request passed to the function contains no attributes. I’ve been struggling for days on this and I’m very confused about….
the codex for mycred_transfer_completed function is here:
http://codex.mycred.me/actions/mycred_transfer_completed/
Again, I understand if this isn’t something you can help with, but any advice/guidance you can share is much appreciated!
September 21, 2017 at 05:00 #174266LauraModeratorHello, will assign the ticket to a higher support level who can help and advise you in your query.
Thanks! ?Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionLaura Solanes - Graphic Designer and Web Designer
Please be patient as I try to answer each topic as fast as i can.
If you like the theme or the support you've received please consider leaving us a review on Themeforest!
Always happy to help you 🙂
September 22, 2017 at 15:36 #174386RaduModeratorHi,
Did you have tried to change the priotiry to the action ? if no try with higher or lowe ones
Also you can try to run the function when on worpdress init action or after_setup_theme or on wp_loaded , try all, see the below snippets
COPY CODEfunction add_points_for_referral( $transfer_id, $request ) { extract ($request); $transfer_amt = $request['amount']; mycred_add( 'Transfer Bonus', 3, 5, $transfer_amt); return; } function pre_add_points_for_referral () { add_action( 'mycred_transfer_completed', 'add_points_for_referral', 10, 2 ); } add_action('init', 'pre_add_points_for_referral'); //add_action('after_setup_theme', 'pre_add_points_for_referral'); //add_action('wp_loaded', 'pre_add_points_for_referral');
Hope it helps
Cheers
RHi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solutionSeptember 23, 2017 at 01:39 #174443psmorrowParticipantThanks!
Mycred documenation was out of date. The request array no longer uses the amount key; instead it uses “charge” and “payout”. Posting my new code for anyone else who might trip over this:COPY CODEadd_action( 'mycred_transfer_completed', 'add_bonus_points', 10, 2 ); function add_bonus_points( $transfer_id, $request ) { // Amount charged $transfer_amt = $request['charge']; // Amount actually transferred $transfer_amt = $request['payout']; // Senders ID $sender = $request['sender_id']; // Recipients ID $recipient = $request['recipient_id']; // Point Type $point_type = $request['point_type']; mycred_add( 'Transfer Bonus', 3, $transfer_amt, 'Bonus'); return; }
September 25, 2017 at 16:07 #174724RaduModeratorHi,
Thank you for providing the working solution!!
Cheers
R.Hi there!!! Help others from the community and mark any reply as solution if it solved your question. Mark as a solution -
AuthorPosts
The forum ‘Plugins questions’ is closed to new topics and replies.