Skip to content

Instantly share code, notes, and snippets.

@danielbitzer
Last active April 29, 2024 13:32
Show Gist options
  • Save danielbitzer/4c127037ee0b012fdf77e7989680563e to your computer and use it in GitHub Desktop.
Save danielbitzer/4c127037ee0b012fdf77e7989680563e to your computer and use it in GitHub Desktop.
AutomateWoo Refer A Friend - Make referral coupons use the user ID of the advocate instead of a random string
<?php
// In addition to adding this code you should set the Coupon Expiry setting to zero to disable coupon expiry
add_filter('automatewoo/referrals/generate_advocate_key', 'my_automatewoo_referrals_generate_advocate_key', 10, 2 );
/**
* @param $key
* @param AW_Model_Referral_Advocate $advocate
* @return int|string
*/
function my_automatewoo_referrals_generate_advocate_key( $key, $advocate ) {
return $advocate->get_id();
}
@emranch31
Copy link

@blazz92 did you find the solution?

@jrick1229
Copy link

Best I could come up with at this time is 'REF[user_id][first_name]': https://gist.github.com/jrick1229/cfd87548c66406a2492576b05fd93579
Using only first name creates advocate issues, as they are indistinguishable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment