Title: Referral Link Shortcode
Last modified: February 23, 2021

---

# Referral Link Shortcode

 *  Resolved [Najm](https://wordpress.org/support/users/gcsaudi/)
 * (@gcsaudi)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/referral-link-shortcode/)
 * 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](https://wordpress.org/support/users/gcsaudi/)
 * (@gcsaudi)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/referral-link-shortcode/#post-14089174)
 * 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 5 years, 3 months ago by [Najm](https://wordpress.org/support/users/gcsaudi/).
    -  This reply was modified 5 years, 3 months ago by [Najm](https://wordpress.org/support/users/gcsaudi/).
 *  Plugin Author [Subrata Mal](https://wordpress.org/support/users/subratamal/)
 * (@subratamal)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/referral-link-shortcode/#post-14099388)
 * [@gcsaudi](https://wordpress.org/support/users/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](https://wordpress.org/support/users/gcsaudi/)
 * (@gcsaudi)
 * [5 years, 3 months ago](https://wordpress.org/support/topic/referral-link-shortcode/#post-14099874)
 * This is AMAZING man, thanks a lot.
 *  [octavo](https://wordpress.org/support/users/octavo/)
 * (@octavo)
 * [5 years ago](https://wordpress.org/support/topic/referral-link-shortcode/#post-14471683)
 * Hello, please where will one insert this code? Thanks.
    -  This reply was modified 5 years ago by [octavo](https://wordpress.org/support/users/octavo/).

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Referral Link Shortcode’ is closed to new replies.

 * ![](https://ps.w.org/woo-wallet/assets/icon-256x256.png?rev=3360666)
 * [Wallet for WooCommerce](https://wordpress.org/plugins/woo-wallet/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-wallet/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-wallet/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-wallet/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-wallet/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-wallet/reviews/)

 * 4 replies
 * 3 participants
 * Last reply from: [octavo](https://wordpress.org/support/users/octavo/)
 * Last activity: [5 years ago](https://wordpress.org/support/topic/referral-link-shortcode/#post-14471683)
 * Status: resolved