Get current language in a GravityForms field

I have a multilingual WPML site. How can I add a field in my form to get the current language?

1. Add this code to your functions.php file

 * Get current language in Gravity Forms
add_filter('gform_field_value_lang', 'wpster_get_language');
function wpster_get_language($value) {
    if (function_exists('icl_object_id')) {
        return ICL_LANGUAGE_CODE;

2. Add an hidden field in your form

On tab “Advanced”:

  • Choose “Allow field to be populated dynamically”
  • Enter the field value on “Parameter Name”. For this example: lang

Submit a Comment

Your email address will not be published.