Gravity forms tricks

Gravity forms is an amazing plugin itself, however there are always some situations when we don’t have the built-in functionality for what we need.

Here we will discuss how to hack gravity forms plugin for WordPress as per our own needs in various situations. This article will keep updating as we get more hacks into it.

Include Widget inside Gravity forms


WordPress: 4.4.2

Gravity forms:

Currency converter: 2.1


For this project, we needed to show a currency converter right inside the forms, where the user will input the currency in input field.

For currency conversion, we’re using plugin:


We’ll be creating a new widget position.

Then we’ll drop the currency conversion widget in that widget position.

We will call that custom widget position inside a gravity forms hook to show that data.

We’ll use PHP output buffering, because calling widget directly outputs (via echo) the output of the widget code, which we don’t want.

Code used:

function custom_currency_converter_widgets_init() {
  register_sidebar( array(
    'name' => 'Currency converter in form',
    'id' => 'custom_currency_converter_1',
    'before_widget' => '<div>',
    'after_widget' => '</div>',
    'before_title' => '<h2 class="rounded">',
    'after_title' => '</h2>',
  ) );
add_action( 'widgets_init', 'custom_currency_converter_widgets_init' );

add_filter( 'gform_field_input', 'custom_currency_converter', 10, 5 );
function custom_currency_converter( $input, $field, $value, $lead_id, $form_id ) {
  // because this will fire for every form/field, only do it when it is the specific form and field
  if ( $form_id == 1 && $field->id == 13 ) {
    if ( is_active_sidebar( 'custom_currency_converter_1' ) ) {
      dynamic_sidebar( 'custom_currency_converter_1' );
      $input = ob_get_contents();
  return $input;

Let me know if there is any confusion or query.

Leave a Reply

Your email address will not be published.