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)
-
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/?=1but it should be
https://mywebsite.com/my-account/?wwref=1It is missing
wwref=
What did i do wrong here?Thanks
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>This is AMAZING man, thanks a lot.
Hello, please where will one insert this code? Thanks.
-
This reply was modified 5 years ago by
octavo.
-
This reply was modified 5 years ago by
Viewing 4 replies - 1 through 4 (of 4 total)
The topic ‘Referral Link Shortcode’ is closed to new replies.