• Resolved Najm

    (@gcsaudi)


    Hi

    is there a way to display the referral link in my website?

    Only the referral link.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter Najm

    (@gcsaudi)

    I was able to make a custom shortcode using this:

    <?php
    if (!defined('ABSPATH')) {
        exit;
    }
    $user_id = get_current_user_id();
    $user = new WP_User($user_id);
    $referral_url_by_userid = 'id' === $settings['referal_link'] ? true : false;
    $referral_url = add_query_arg($referral->referral_handel, $user->ID, wc_get_page_permalink('myaccount'));
    if ($referral_url_by_userid) {
        $referral_url = add_query_arg($referral->referral_handel, $user->ID, wc_get_page_permalink('myaccount'));
    }
    ?>
    <span>
        <?php _e('Your referral URL is:', 'woo-wallet'); ?>
        <input type="text" readonly="" id="referral_url" value="<?php echo $referral_url; ?>" />
        <div class="referral-tooltip">
            <button onclick="referralTooltip()" onmouseout="referralTooltipOutFunc()">
                <span class="referral-tooltiptext" id="referral_tooltip"><?php _e('Copy to clipboard', 'woo-wallet'); ?></span>
                <?php _e('Copy', 'woo-wallet'); ?>
            </button>
        </div>
    </span>

    But the displayed link is
    https://mywebsite.com/my-account/?=1

    but it should be
    https://mywebsite.com/my-account/?wwref=1

    It is missing wwref=
    What did i do wrong here?

    Thanks

    • This reply was modified 3 years, 9 months ago by Najm.
    • This reply was modified 3 years, 9 months ago by Najm.
    Plugin Author Subrata Mal

    (@subratamal)

    @gcsaudi

    Please use updated code.

    if (!defined('ABSPATH')) {
        exit;
    }
    $user_id = get_current_user_id();
    $user = new WP_User($user_id);
    $settings = get_option('woo_wallet_referrals_settings');
    $referral_url_by_userid = 'id' === $settings['referal_link'] ? true : false;
    $referral_url = add_query_arg(apply_filters('woo_wallet_referral_handel', 'wwref'), $user->ID, wc_get_page_permalink('myaccount'));
    if ($referral_url_by_userid) {
        $referral_url = add_query_arg(apply_filters('woo_wallet_referral_handel', 'wwref'), $user->ID, wc_get_page_permalink('myaccount'));
    }
    ?>
    <span>
        <?php _e('Your referral URL is:', 'woo-wallet'); ?>
        <input type="text" readonly="" id="referral_url" value="<?php echo $referral_url; ?>" />
        <div class="referral-tooltip">
            <button onclick="referralTooltip()" onmouseout="referralTooltipOutFunc()">
                <span class="referral-tooltiptext" id="referral_tooltip"><?php _e('Copy to clipboard', 'woo-wallet'); ?></span>
                <?php _e('Copy', 'woo-wallet'); ?>
            </button>
        </div>
    </span>
    Thread Starter Najm

    (@gcsaudi)

    This is AMAZING man, thanks a lot.

    Hello, please where will one insert this code? Thanks.

    • This reply was modified 3 years, 6 months ago by octavo.
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Referral Link Shortcode’ is closed to new replies.