gform_personal_data

Description

The “gform_personal_data” filter in Gravity Forms allows custom data exporter and erasers to be registered with WordPress so they are also run when WP data cleanup occurs.

This hook works with WordPress’s Export Personal Data and Erase Personal Data Tools.

Usage

add_filter( 'gform_personal_data', 'your_function_name', 10, 2 );

Parameters

  • $custom_items array

    An array of the custom export/erase functions to be run. The items in the array display on the Personal Data Settings page for selection.

  • $form Form Object

    The form object.

Examples

add_filter( 'gform_personal_data', 'filter_gform_personal_data', 10, 2 );
function filter_gform_personal_data( $items, $form ) {
       $items['test'] = array(
          'label'             => 'A custom item',
          'exporter_callback' => 'gf_custom_data_exporter',
          'eraser_callback'   => 'gf_custom_data_eraser',
      );

      return $items;
 }

 function gf_custom_data_exporter( $form, $entry ) {
       $data = array(
        'name'  => 'My Custom Value',
          'value' => 'ABC123',
      );
      return $data;
 }

 function gf_custom_data_eraser( $form, $entry ) {
      // Delete or anonymize some data
 }

Placement

This code should be placed in the functions.php file of your active theme.

Since

This filter was added in Gravity Forms 2.4.

Source Code

This filter is located in GF_Personal_Data::get_custom_items() in gravityforms/includes/class-personal-data.php.