Changing the Affiliate Referal Code

Hi,

I installed the Affiliates plugin.

I also installed a plugin that allows users to register without the need to register a username. The plugin , called Register Plus Redux, essentially uses the email address as the username. The idea is to make registration and logging in as easy as possible.

There is a slight hicup however, which pertains to the privacy of users wishing to become an affiliate via Affiliates plugin. Instead of the affiliate code looking link looking like "http://www.websiteurl.com?ref=username-001", for example, it now looks like "http://www.websiteurl.com?ref=name@emailaddress.com-001".

The easiest solution might be to reference the user's unique MySQL "wp_users" table record ID number. The affiliate code could then look like "http://www.websiteurl.com?ref=50-001".

Can you offer any suggestions or code a plugin modification for me?
I would be happy to pay for the work if you can give me a quote.

Perhaps this feature could be incorporated into future Affiliates plugin updates :wink:

I look forward to your response.

Kind regards,

Regards,

Yousef

  • PC
    • WPMU DEV Initiate

    Hello Yousef,

    Greetings and thanks for your post.

    The plugin uses usernames in the affiliate links by default so its showing up the users email address as you are using them as a username.

    However, there should be a way to change it to something else.

    While we don't undertake custom work, you can use our job boards if you want someone to modify the plugin for you.

    Before you do that, let me seek our developer's assistance to see if this is something possible with ease. I tried to look into the code but could not find the file where it defines the affiliate url

    I have sent a note to @Barry and he should be here sooner than later.

    Cheers
    PC
    Sales &Support

  • PC
    • WPMU DEV Initiate

    Hello Yousef,

    Thanks for standing by and sorry for the delay.

    I have sent another note to our lead developer @Barry

    Sorry for the delay here as Barry is busy working on an update of our Membership plugin however I will try to get him here as soon as possible :slight_smile:

    Cheers
    PC
    Sales &Support

  • Barry
    • DEV MAN’s Mascot

    The reference (once generated) is stored in the usermeta table with a key of 'affiliate_reference' - you must ensure that the usermeta is unique for each user.

    $reference = get_user_meta($user_ID, 'affiliate_reference', true);

    You can change the referral code that is generated and checked by changing the relevant part of the plugin.

    It is generated by appending the userlogin to a unique number - the line that does it is 567 of affiliateadmin.php in the classes directory of affiliateincludes

    It looks like this:
    $reference = $user->user_login . '-' . strrev(sprintf('%02d', $user_ID + (int) AFFILIATE_REFERENCE_KEY));

    The number is built from the user_id added to a number that is stored and can be changed in your wp-config.php file. You could change the $user->user_login part to anything you want (e.g. 'affiliate' ), as the number part ensures it is unique.

    E.g.
    $reference = 'affiliate-' . strrev(sprintf('%02d', $user_ID + (int) AFFILIATE_REFERENCE_KEY));

  • linkreserve
    • New Recruit

    Hi Barry,

    Thank you very much for taking the time to respond in detail.

    I changed the line of code as advised (please see attachment) and created a new user account then enabled the user's affiliate links. Unfortunately, changing the line of code seems to not change the affiliate referral link in any way.

    Please advise.

    Thank you.

    Regards,

    Yousef

  • linkreserve
    • New Recruit

    Hi PC,

    Thank you for following up with me.

    Unfortunately, the solution described above has not worked and has left me feeling somewhat disappointed and discouraged. Was the proposed solution tested?

    Don't worry, I am going to search the web for other solutions.

    Thank you.

    Regards,

    Yousef

  • Barry
    • DEV MAN’s Mascot

    Unfortunately, the solution described above has not worked and has left me feeling somewhat disappointed and discouraged. Was the proposed solution tested?

    Hi, the new functionality is in the latest version and works for *new* signups. It won't change already existing users (as changing their references will break all their links).

    If you want to change someones referral code then you need to make the change either in your wp-config.php or directly in the affiliateincludes/includes/config.php, then disable their affiliate status (set the affiliate status to No in their admin panel) and set it back to Yes and the new code will be applied.

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.