Pass affiliate info into submitted form

Posted in

I am using affiliates pro and contact form 7 integration. When the form is submitted I want the notification email from contact form 7 to include affiliate information. It doesn’t matter if it is the id, email, or the name. I just need the submitted form to have some identification of the referring affilitate. Thanks

10 Responses to Pass affiliate info into submitted form

  1. mikey300 October 31, 2013 at 11:22 pm #

    Nevermind, I got it. Thank you so much for your help

    • antonio November 3, 2013 at 8:09 pm #

      ok 😉

  2. mikey300 October 31, 2013 at 12:41 pm #

    I decided to use formidablepro forms instead of contact7. Below is the code I am using and am getting the affiliate id just fine. I am trying to figure out what to change to pull up the email instead. If you will notice at the bottom, the new value for field 220 is where I am pulling up the Affiliates Service. Thanks for your help.

    class Affiliates_Service {

    /**
    * Obtain the referring affiliate's id.
    * @param string $service by name
    * @return int affiliate id or false if none applies
    */
    public static function get_referrer_id( $service = null ) {
    $affiliate_id = false;
    switch ( $service ) {
    default :
    if ( isset( $_COOKIE[AFFILIATES_COOKIE_NAME] ) ) {
    $affiliate_id = affiliates_check_affiliate_id_encoded( trim( $_COOKIE[AFFILIATES_COOKIE_NAME] ) );
    }
    }
    if ( !$affiliate_id ) {
    if ( get_option( 'aff_use_direct', true ) ) {
    // Assume a direct referral
    $affiliate_id = affiliates_get_direct_id();
    }
    }
    return apply_filters( 'affiliates_service_affiliate_id', $affiliate_id, $service );
    }

    }

    add_filter('frm_get_default_value', 'my_custom_default_value', 10, 2);
    function my_custom_default_value($new_value, $field){
    if($field->id == 220){ //change 220 to the ID of the field
    $new_value = $aff_id = Affiliates_Service::get_referrer_id();
    $current_aff = affiliates_get_affiliate( $aff_id );

    }
    return $new_value;
    }

  3. mikey300 October 29, 2013 at 12:47 pm #

    Thanks for all your help. But, I cant get this to work.
    $email = $current_aff[’email’];

    • antonio October 31, 2013 at 11:17 am #

      Hi,
      I have tested this and looks work fine.

      function cf7_email_affiliates_wpcf7_before_send_mail (&$data) {
      if ( !class_exists("Affiliates_Service" ) ) {
      require_once( AFFILIATES_CORE_LIB . '/class-affiliates-service.php' );
      }
      $aff_id = Affiliates_Service::get_referrer_id();
      $current_aff = affiliates_get_affiliate( $aff_id );
      if ($current_aff !== null) {
      $data->posted_data['your-message'] .= "Affiliate: " . $aff_id . "-" . $current_aff['email'];
      }
      }
      add_action("wpcf7_before_send_mail", "cf7_email_affiliates_wpcf7_before_send_mail");

      If your message field has another name, you must change “your-message”.
      cheers

  4. mikey300 October 28, 2013 at 5:33 pm #

    what would I need to change if I wanted to get the email of the affiliate instead of the id?

    • antonio October 29, 2013 at 5:44 am #

      Hi,
      you can get the email: $email = $current_aff['email'];
      If you need get another data, have a look to affiliates_get_affiliate function.
      cheers

  5. mikey300 October 28, 2013 at 3:34 pm #

    Nevermind. Had a character off. Worked like a charm, Thanks a ton!

  6. mikey300 October 28, 2013 at 3:08 pm #

    ok. thanks for your input antonio. I used the get affiliate code but it broke somewhere. here is what i am getting.

    Fatal error: Class ‘Affiliates_Service’ not found in /home/content/h/a/l/halesmith/html/wp-content/themes/memorable/functions.php on line 44

  7. antonio October 27, 2013 at 5:21 pm #

    Hi,
    you could use “wpcf7_before_send_mail” hook. Here you have more information.
    To get the affiliate, you can use (more information on Affiliates Documentation):
    $aff_id = Affiliates_Service::get_referrer_id();
    $current_aff = affiliates_get_affiliate( $aff_id );

    cheers

We use cookies to optimize your experience on our site and assume you're OK with that if you stay.
OK, hide this message.

Affiliates · Contact · Jobs · Terms & Conditions · Privacy Policy · Documentation · Downloads · Useful Plugins · My Account

Share