affiliates_stored_affiliate not passing value for $affiliate_user_id

We’re using the default affiliate registration form with some additional fields added.

We added a custom function (it extracts the new registrant info from wp_usermeta and packages all the info in an email sent to one of our email addresses) and the function triggers when a new user account for an affiliate has been made.

Based on your documentation the action is supposed to pass:
– $affiliate_id int the new affiliate’s ID
– $affiliate_user_id int the new user’s ID which is related to the affiliate entry

Our custom function was working with the previous version of the Affiliate Enterprise plugin without any problems. Now however, the emails we’ve been getting show only the Affiliate ID, with blank fields for all the info that should have been present if a valid User ID had been passed.

Hoping for a prompt resolution to this issue.

5 Responses to affiliates_stored_affiliate not passing value for $affiliate_user_id

  1. Adam September 11, 2016 at 6:22 pm #

    Thanks Antonio!

    We actually have those lines in wp-config already, but since the additional parameters in the add_action() function are optional, no error or warnings were generated when the 2nd parameter got dropped.

    Thanks for pointing out the fact that we had to add an explicit value for the $accepted_args parameter! Our bad 😀

    • antonio September 12, 2016 at 10:15 am #

      Perfect 😉

  2. Adam September 7, 2016 at 3:40 pm #

    See custom function below. Commented lines are my current work-around, since only the affiliate id value gets passed(!)

    /* Send email to [edited] containing all the info of newly-added school affiliates */
    add_action( ‘affiliates_stored_affiliate’, ‘send_registered_affiliate_info’ );
    function send_registered_affiliate_info( $affiliate_id, $affiliate_user_id ) {
    //global $wpdb;
    //$results = $wpdb->get_results(“select user_id from “.$wpdb->prefix.”aff_affiliates_users where affiliate_id=’$affiliate_id’ limit 1”, OBJECT);
    $user_id = $affiliate_user_id; //$results[0]->user_id;
    $school_name = get_user_meta( $user_id, ‘school_name’, true );
    $first_name = get_user_meta( $user_id, ‘first_name’, true );
    $last_name = get_user_meta( $user_id, ‘last_name’, true );
    $user_title = get_user_meta( $user_id, ‘user_title’, true );
    $userinfo = get_userdata( $user_id );
    $user_email = $userinfo->user_email;
    $street_address = get_user_meta( $user_id, ‘street_address’, true);
    $town_city = get_user_meta( $user_id, ‘city’, true);
    $state = get_user_meta( $user_id, ‘state’, true);
    $zip = get_user_meta( $user_id, ‘zip’, true);
    $zip_4_digit = get_user_meta( $user_id, ‘zip_4_digit’, true);
    $phone = get_user_meta( $user_id, ‘phone’, true);
    $schoollogo = get_user_meta( $user_id, ‘school_logo’, true);
    $salesrep_refid = get_user_meta( $user_id, ‘salesrep_refid’, true);
    $student_enrollment = get_user_meta( $user_id, ‘total_student_enrollment’, true);
    $emailmsg = “New School Affiliate registered with the ff. info:\r\n\r\n”;
    $emailmsg .= “Account Info ————-\r\n”;
    $emailmsg .= ‘ Affiliate ID : ‘ . $affiliate_id . “\r\n”;
    $emailmsg .= ‘ User Account ID : ‘ . $user_id . “\r\n\r\n”;
    $emailmsg .= “Contact Info ————-\r\n”;
    $emailmsg .= ‘ First Name : ‘ . $first_name . “\r\n”;
    $emailmsg .= ‘ Last Name : ‘ . $last_name . “\r\n”;
    $emailmsg .= ‘ Title : ‘ . $user_title . “\r\n”;
    $emailmsg .= ‘ Phone : ‘ . $phone . “\r\n\r\n”;
    $emailmsg .= ‘ E-mail : ‘ . $user_email . “\r\n\r\n”;
    $emailmsg .= “School Info ————-\r\n”;
    $emailmsg .= ‘ School Name : ‘ . $school_name . “\r\n”;
    $emailmsg .= ‘ Street Address : ‘ . $street_address . “\r\n”;
    $emailmsg .= ‘ Town/City : ‘ . $town_city . “\r\n”;
    $emailmsg .= ‘ State : ‘ . $state . “\r\n”;
    $emailmsg .= ‘ ZIP Code : ‘ . $zip . “\r\n”;
    $emailmsg .= ‘ ZIP 4-digit Code : ‘ . $zip_4_digit . “\r\n”;
    $emailmsg .= ‘ Student enrollment : ‘ . $total_student_enrollment . “\r\n”;
    $emailmsg .= ‘ School Logo URL : ‘ . $schoollogo . “\r\n\r\n”;
    $emailmsg .= “Referral Info ————-\r\n”;
    $emailmsg .= ‘ Referring Sales Rep ID : ‘ . $salesrep_refid . “\r\n”;
    $email = ‘[edited]’;
    $subject = ‘New School Affiliate Registered’;
    $from = “PreferredEssentials.com \r\n”; // . get_option(‘admin_email’) . “>\r\n”;
    $headers = ‘From: ‘.$from . “\r\nReturn-Path: {no-reply@preferredessentials.com}”; //.get_option(‘admin_email’).”}”;
    wp_mail( $email, $subject, $emailmsg, $headers );
    }

    • antonio September 8, 2016 at 10:09 am #

      Thanks,
      please call the action indicating that there are two params:
      add_action( 'affiliates_stored_affiliate', 'send_registered_affiliate_info', 10, 2 );
      The other code seems correct.
      If you enable the debug, editing the wp-config.php and replacing the following line
      define('WP_DEBUG', false );
      with these lines
      define('WP_DEBUG', true );
      define('WP_DEBUG_DISPLAY', false);
      define('WP_DEBUG_LOG', true );

      Can help you to find error. If errors exist then a file named debug.log under wp-content folder will be created.
      Kind Regards,
      Antonio B.

  3. antonio September 7, 2016 at 8:07 am #

    Hi Adam,
    please say me the hook that you are using. If you send me your custom function ( antonio[at]itthinx[dot]com ), I can have a look at this.
    Kind Regards,
    Antonio B.

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