Hey @serefor,
Thank you for reaching out! I believe that this can be done via a hidden input field and some custom code.
Here’s the code:
function slicewp_custom_add_gravity_forms_field_value_affiliate( $value ) {
if ( ! function_exists( 'slicewp_get_referrer_affiliate_id' ) ) {
return $value;
}
$affiliate = slicewp_get_affiliate( slicewp_get_referrer_affiliate_id() );
if ( is_null( $affiliate ) ) {
return $value;
}
$user = get_userdata( $affiliate->get( 'user_id' ) );
$value = $user->user_login; // Value will be set to the user's username.
return $value;
}
add_filter( 'gform_field_value_affiliate', 'slicewp_custom_add_gravity_forms_field_value_affiliate' );
The code uses a hook provided by Gravity Forms (you can read more about this hook here: https://docs.gravityforms.com/gform_field_value_parameter_name/) to add the username of the affiliate user to a hidden field.
To have the value appear in the hidden field, make sure to have the “Allow field to be populated dynamically” option checked in the field editor’s advanced tab.
Also, make sure to set the “Parameter Name” option to “affiliate”.
Please try it out and let me know how it goes.
Thank you and best wishes,
Mihai
-
This reply was modified 1 year, 4 months ago by
iova.mihai.