• Resolved garrretts

    (@garrretts)


    Hi, great plugin! Thanks for making it available, I am currently testing it and considering purchasing. However, I am trying to generate an affiliate url for the current page and cannot get it to work:

    As far as I can see, there is not shortcode in SliceWP that allows me to automatically generate the affiliate url for the current page, so I created a code snippet I put into a WPCode as follows (which I trigger with a shortcode that I am placing in a test page) – however it’s not working and I cannot figure out what the issue is as I am not a programmer.

    If you wouldn’t mind assisting please, that would be very much appreciated, Thanks!

    <?php
    global $wp;
    $current_url = home_url(add_query_arg(array(), $wp->request));
    $referal_link = slicewp_get_affiliate_url( 10 , $current_url );
    print($referal_link);
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author iova.mihai

    (@iovamihai)

    Hey @garrretts,

    Thank you for reaching out! From what I see, the code you’ve shared is working correctly. It returns the referral link for affiliate with ID 10.

    For a complete shortcode code, please add this snippet:

    function slicewp_custom_current_page_referral_link() {
    	
    	global $wp;
    
    	$current_url  = home_url( add_query_arg(array(), $wp->request) );
    	$referal_link = slicewp_get_affiliate_url( 10 , $current_url );
    	
    	return ( $referal_link ? $referal_link : '' );
    	
    }
    add_shortcode( 'slicewp_custom_current_page_referral_link', 'slicewp_custom_current_page_referral_link' );

    Then, you can use the “[slicewp_custom_current_page_referral_link]” shortcode in your website. It will output the current page’s URL as a referral link for affiliate with the ID 10.

    To have the code output the referral link for the currently logged-in affiliate, replace the “10” string from your code with this function: slicewp_get_current_affiliate_id()

    The function will return the current affiliate’s unique ID.

    Thank you and best wishes,

    Mihai

    Thread Starter garrretts

    (@garrretts)

    Hi Mihai,

    That’s great, it’s working for me now.

    Thanks so much for your help!

    Garrett

    Plugin Author iova.mihai

    (@iovamihai)

    Hey @garrretts,

    No worries whatsoever! Happy I could help you out.

    Wishing you a fantastic day ahead!

    Mihai

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Create affiliate url for current page’ is closed to new replies.