Use this if you want to track referrals with Refer a Friend but reward advocates in your own way, for example with a custom points system or a manual payout.
If you only want points or store credit, you may not need code. See Reward advocates with points or store credit.
Read Add code snippets safely before using these snippets. Checked with version 4.4.12.
Option 1: stop coupons, keep everything else
This stops reward coupons and their emails. Referral orders are still recorded, referral counts still go up, and the gens_before_generate_user_coupon action still fires, so you can hook your own reward there.
add_filter( 'gens_raf_generate_coupon', '__return_false' );
add_action( 'gens_before_generate_user_coupon', function ( $user_id, $type, $order ) {
if ( 'referrer' !== $type || ! is_numeric( $user_id ) ) {
return;
}
// Give your own reward to the advocate with ID $user_id here.
}, 10, 3 );
$type is referrer for the advocate, friend for Post-First Purchase coupons and registration for registration rewards. For guest advocates, $user_id is their ref… code, not a number.
The friend’s first-purchase discount isn’t affected. It’s a normal WooCommerce coupon applied at checkout.
Option 2: run the reward step yourself
This removes the plugin’s reward step completely. No coupons, no emails, and referral counts don’t go up until you run it yourself.
add_action( 'init', function () {
if ( class_exists( 'WPGENS_RAF_Order' ) ) {
remove_action(
'woocommerce_order_status_' . WPGENS_RAF_Order::get_order_status(),
array( 'WPGENS_RAF_Order', 'gens_maybe_create_send_coupon' ),
10
);
}
} );
To run the reward step later for an order, for example after your own approval process:
WPGENS_RAF_Order::gens_maybe_create_send_coupon( $order_id );
Running it twice for the same order creates two sets of coupons.
Earlier versions of this page used WPGens_RAF::instance()->order_object. That property no longer exists, so the old snippet does nothing. Replace it with one of the options above.
Check it worked
Place a test referral order and set it to the reward status. Marketing → Coupons shouldn’t have a new RAF- coupon, and the order’s Refer a Friend box should still show the referral.