Note: This hook replaces the deprecated gform_after_duplicate_form hook.
Description
The gform_post_form_duplicated action in Gravity Forms is triggered after a form is duplicated, allowing further actions to be performed. The hook provides the ID of the form duplicated and the ID of the new form created.
Usage
add_action( 'gform_post_form_duplicated', 'my_function', 10, 2 );
Parameters
| Parameter | Type | Description |
|---|---|---|
$form_id | int | The ID of the form being duplicated. |
$new_id | int | The ID of the newly created, duplicate form. |
Examples
Run a custom action after duplicating a form.
function my_function() {
//Do something here
}
add_action( 'gform_post_form_duplicated', 'my_function', 10, 2 );
Placement
This code can be used in the functions.php file of the active theme, a custom functions plugin, a custom add-on, or with a code snippets plugin.
See also the PHP section in this article: Where Do I Put This Code?
Source Code
This action hook is located in GFFormsModel::duplicate_form() in forms_model.php.