PLEASE NOTE: These forums are no longer utilized and are provided as an archive for informational purposes only. All support issues will be handled via email using our support ticket system. For more detailed information on this change, please see this blog post.

Pulling Affiliate Plugin ID into Hidden form Field

  1. I'd like to pull an affiliate ID form the affiliate plugin I'm using into the Gravity form on my product page. The Affiliate guy says:

    You can obtain the referrer ID by calling Affiliates_Service::get_referrer_id().

    Uncertain how to go about including this into my Gravity form through a hidden field.
    Any ideas?

    This is at the plugin - http://www.itthinx.com/plugins/affiliates/affiliates-shortcodes

    Posted 12 years ago on Wednesday August 22, 2012 | Permalink
  2. You probably want to use the gform_field_value_$parameter_name filter to call that Affiliates_Service::get_referrer_id() function from your affiliate plugin

    http://www.gravityhelp.com/documentation/page/Gform_field_value_$parameter_name

    If you have a hidden field in your form which is set to be populated dynamically (check that box on the advanced tab for your hidden field), and that field has a parameter name of "referrer_id" you will call the filter like this:

    [php]
    add_filter("gform_field_value_referrer_id", "populate_referrer_id");

    Then, you will write a function called populate_referrer_id which will call the Affiliates_Service::get_referrer_id(), maybe like this:

    [php]
    add_filter('gform_field_value_referrer_id', 'populate_referrer_id');
    function populate_referrer_id($value) {
        $referrer_id = Affiliates_Service::get_referrer_id();
        return $referrer_id;
    }

    Here is a more verbose example. You are using the same procedure, but your function value comes from the affiliate plugin's function, not built in WordPress functions.

    http://www.gravityhelp.com/documentation/page/Dynamically_Populating_the_Post_Author

    Let us know if that works out for you.

    Posted 12 years ago on Friday August 24, 2012 | Permalink