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 2 years, 5 months ago by
iova.mihai.
Hello @iovamihai,
The code works perfectly!
Thank you so much for your speedy and generous help. I couldn’t have done it without your support.
You saved my day.
Many congratulations for this amazing plugin.
Regards!
Serefor
Hey @serefor,
I’m really happy to hear the code worked as you need it! Happy I could help you.
Also, thank you for the kind words about SliceWP!
Considering that you’re enjoying the plugin, if it’s not too much to ask, could you please leave a review for SliceWP on the WordPress plugin directory (here: https://wordpress.org/support/plugin/slicewp/reviews/)?
Thank you and best wishes,
Mihai
Hey @iovamihai,
Of course I did! I left a fully deserved review.
Thanks again!
Serefor
Hey @serefor,
Glad I could help you out.
Thank you so much for taking the time to write this review! I really appreciated!
Best wishes,
Mihai