Additional security: Check unique user meta

READ FIRST: This code needs to be added at the end of the functions.php file. If you are familiar with editing functions.php, feel free to continue reading. If you haven’t done this before, adding this code in the wrong place might bring the site down and the only way to access it is by editing functions.php file again via FTP. Feel free to contact us if you need help!

By default, the WooCommerce Refer a Friend plugin checks that the shipping address and email address are unique to prevent fraud. If you have some unique data that every customer needs to have, you can use the code below to check if that data between the referred person and referral is the same, and if it is, prevent the use of the referral system:

function gens_check_social_num($raf_info,$order,$referrer_id) {
    $customer_id            = $order->get_user_id();
    $customer_number = get_user_meta($customer_id, "social_number", true);
    $referral_number = get_user_meta($referrer_id, "social_number", true);
    $enable_referral  = "yes";
    if(!empty($customer_number) && !empty($referral_number) && ($customer_number == $referral_number)) {
      	$enable_referral = "no";

    if($enable_referral === "no") {
    	$raf_info = array("info" => "Customer added same social security number", "generate" => "false", "increase_referrals" => "false");
    } else {
    	$raf_info = array("info" => "All good, coupon will be generated.", "generate" => "true", "increase_referrals" => "true");
    return $raf_info;
add_filter( 'gens_raf_order_info', 'gens_check_social_num',10,3);

Just make sure to change “social_number” to the correct user meta. 

What they say

Trusted by 7000+ customers

Our plugins are used by more than 7000 websites across the globe. All of our plugins are rated 5 stars on Don’t just take our word for it, check what others are saying about WPGens.

I bought and tested the plugin with WooCommerce Subscription and it works like a charm. I had some specific questions to the developer and he responded very fast and helped me. I suggest the plugin!

Refer a Friend PREMIUM

If your looking to set up a referral program on your WooCommerce site to boost up your site sale “Refer A Friend for WooCommerce by WPGens” is your plugin to go for. Little blown away with an amazing support provided from (Goran) the plugin working exactly what you want to set up a referral system. Good job guys!

Refer a Friend PREMIUM

We deal with dozens of applications and plugins on a daily basis. Many of them are excellent, but few have truly excellent support. The Refer A Friend plugin is one of them: the response to my questions is always fast, friendly and very helpful.

Refer a Friend PREMIUM

This plugin is awesome. It looks good, it’s light weight, has great support – everything you can expect from a paid plugin, only it’s free!!!!

Swifty Bar

Read all testimonials on WordPress Repository.

Get notified when we add new plugins.

We do not publish plugins often, but when we do, it's something awesome. No spam, we promise.