2

We have a wordpress website build using divi builder theme. Currently we have the issue where we are trying to manage traffic/ affiliates.

Someone might browse to our site www.domain.com/?ref=abcd1234

On the main home page which is built using divi, it uses the button module and what we are trying to do is modify the link on that button as follows.

Current link : https://www.remotesite.com/

to

New Link : https://www.remotesite.com/?ref=abcd1234

Unfortunately I cannot work out how to retrieve that ref variable and then use it within the divi button module. If this was a normal html/php site, it would be a simple case of

<a href="https://www.remotesite.com/?ref=<?php echo $_REQUEST['ref']; ?>">CLICK HERE TO JOIN</a>

Unfortunately wordpress combined with divi builder is not allowing that.

I did attempt modifying the child functions.php as follows

function get_affiliate_code($ref ) {
    if( ! is_single() )
        return;
/*
    $code = isset($_GET['ref'] ) ? sanitize_text_field($_GET['ref']) : '';
    $code = isset( $_GET['referralCode'] ) ? sanitize_text_field( $_GET['referralCode'] ) : '';
 */
 $code = 'mario1234';
 
 return $code;   
}

add_shortcode('affiliatecode', 'get_affiliate_code');

And then appending [affiliatecode] shortcode in the divi builder button link code, but all it does is show the link as https://www.remotesite.com/?ref=[affiliatecode]

I'm aware there is code commented out in that function, I was trying to see if I could at least get it to parse a static variable, but failed on that as well.

Hoping someone can point out what I'm doing wrong here.

user1648968
  • 143
  • 2
  • 13

0 Answers0