How to get Referring Affiliate and Save it as User Meta in Wordpress?

Discussion in 'aMember Pro v.4' started by sebascar, May 31, 2013.

  1. sebascar

    sebascar CEO of ScarMarketing

    Joined:
    Apr 27, 2012
    Messages:
    5
    Hi, :) any suggestion?

    I'd need to do this customization to a Wordpress website:

    1. An affiliate (a) sends - through his link - a prospect (b) to my website (I run a membership).
    2. The prospect (b) register to the membership

    Now, in a wordpress page I need to show to (b) the referring username (a) - in other words the guy showed here.

    I'm thinking about two solutions:

    1. The best, would be to save the (a) username as a Custom User meta in Wordpress when the WP user is created.
    2. or at least get - somehow - the referring username by a direct SQL query...

    I'm not asking you the solution :D I'd like to know if you think this is somehow possible or it's inhuman :D

    If you have any idea/suggestion to do this in the smartest way possible? Thanks. ^__^
  2. alexander

    alexander Administrator Staff Member

    Joined:
    Jan 8, 2003
    Messages:
    6,279
    I personally think the method 1 is better because you will update wordpress database only once and won't execute additional queries each time when you should display referred user info.
    Check function update_meta_tags in /amember/application/default/plugins/wordpress/wordpress.php
    To get referred user login use this code:
    if($user->aff_id){
    $affiliate = Am_Di::getInstance()->userTable->load($user->aff_id);
    $login = $affiliate->login;
    }

Share This Page