• Hello,
    I am wondering if it would be possible to generate a ‘referral link’, or ‘invite code’ for each user that registers. This way, whenever they invite a friend, they and their friend get a new ‘premium’ role.
    Thanks heaps.

Viewing 4 replies - 1 through 4 (of 4 total)
  • I did this by adding a hidden ref_id field. Users can now register on another user’s profile page, and ref_id will show who invited whom.

    The page that is specified as a profile becomes a referral link. In this case, the profile form may not be on this page, which allows you to create any content as the site of the inviting user.

    And for the profile to have a separate page with a separate form.

    Hey, could you go into some more detail on this? It sounds awesome!

    It works for me so:

    1. Create a field in the registration form ref_id
    2. I place the shortcode of the form on the page that is listed as the profile page.
    3. I got the site.loc/user/userlogin
    4. Create a php file such as refsite.php and its code


    // absolute URI in multisite aware environment
    $uParts = parse_url( home_url() );
    $url = "{$uParts['scheme']}://{$uParts['host']}" . add_query_arg( NULL, NULL );
    $url = $_SERVER['REQUEST_URI']; // получаем логин для сборки без multisite
    $uParts=explode('/', $url);
    $login = $uParts[4];
    // get user id by login
    global $wpdb;
    $query = "SELECT * FROM wp_usermeta where meta_key = 'nickname' and meta_value = '{$login}'";
    $sponsor = $wpdb->get_row( $query );	
    $sponsorID = $sponsor->user_id;
    	$sponsorID = 1;
    // Take out the field user
    $fields = array('first_name', 'last_name', 'city_user', 'country', 'mobile_number', 'skype' ,);
    $user_fields = array();
    for($i=0; $i<count($fields); $i++){
    	$query = $wpdb->get_row( "SELECT * FROM wp_usermeta where meta_key = '{$fields[$i]}' and user_id = '{$sponsorID}'");	
    	$user_fields[$fields[$i]] = $query->meta_value;
    $user_id = get_current_user_id();


    <script type="text/javascript">
    jq = jQuery.noConflict();
    	jq('.um-field-ref_id input').val('<?php echo $sponsorID; ?>');
    	jq('.um-field-ref_id input').attr('readonly','readonly');

    5. I connect this plugin in php profile page template
    <?php require_once(__DIR__.'/php/lp.php'); ?>
    6. Now in the field ref_id substitutes the id of the owner of the profile.
    7. After registration, the user in the submitted field is specified and our ref_id
    8. I see on the page of all who registered through my page
    (Here’s another code but I’ll show you what it looks like)

    If you want more detail send me an email alexgminfo.dev @ gmail.com

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Referral Link/Invite Code’ is closed to new replies.