1

I have very basic coding knowledge. Not nearly enough to add a second code to my functions.php. A developer (who is no longer available for help) coded the below. I recognize the field ID and where he placed it (id == 263). Now, I need to add a second field ID (id == 359). I don't know how to write the code properly for the second ID.

/* Deal with link between Affiliate WP plugin and Formidable Forms */
/* First, let's constantly check for URL params that might relate to an Affiliate */
add_action( 'init', 'process_affwp_vals' );
function process_affwp_vals() {
     if( isset( $_GET['v'] ) ) {
          setcookie("affwp_value", urlencode($_GET['v']), time()+86400); //one day expiration
     }
     if( isset( $_GET['ref'] ) ) {
          setcookie("affwp_username", urlencode($_GET['ref']), time()+86400); //one day expiration
     }
}
add_filter('frm_get_default_value', 'my_custom_default_value', 10, 2);
function my_custom_default_value($new_value, $field){
    if($field->id == 236){ //Affiliate Tracking Field ID
        if(isset($_COOKIE['affwp_username'])) {
            $new_value = ($_COOKIE['affwp_username']);
        }
    }
    return $new_value;
}
Phix
  • 9,364
  • 4
  • 35
  • 62
Ginger_N
  • 39
  • 2

0 Answers0