View Categories

How to manually change users referral code/link?

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!

If you want to manually edit a referral code for a user – maybe they want a referral code that is easier to remember – add this code to your function.php file.

add_action( 'show_user_profile', 'gens_raf_user_referral_fields' );
add_action( 'edit_user_profile', 'gens_raf_user_referral_fields' );
function gens_raf_user_referral_fields( $user ) 
{ ?>
    <h3>Module Options</h3>

    <table class="form-table">
        <tr>
            <th><label for="gens_referral_id">Refer a friend link</label></th>
            <td>
                <input id="gens_referral_id" name="gens_referral_id" type="text" value="<?php echo  get_the_author_meta( 'gens_referral_id', $user->ID ); ?>" />
            </td>
        </tr>
    </table>
<?php }

add_action( 'personal_options_update', 'save_gens_raf_user_referral_fields' );
add_action( 'edit_user_profile_update', 'save_gens_raf_user_referral_fields' );

function save_gens_raf_user_referral_fields( $user_id ) 
{
    if ( !current_user_can( 'edit_user', $user_id ) ) { return false; }

    update_usermeta( $user_id, 'gens_referral_id', $_POST['gens_referral_id'] );
}

After that, go to admin dashboard -> Users, and click on one of the users that you want to edit. Then find a Refer a Friend input field and change it there, it should look like the one in the image below. After changing, click save and that’s it.

WooCommerce Refer a Friend How to manually change users referral code or link? referral link
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 WordPress.org. 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
@rinpocse91

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
@samroon007

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
@smartDIYer

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
@ofirbeigel

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.