Filter Copy Cat Fields

Add copy cat class to fields programmatically.

Code

Filename: gpcc-set-copy-cat-fields.php

<?php
/**
 * Gravity Perks // Copy Cat // Filter Copy Cat Fields
 * https://gravitywiz.com/documentation/gravity-forms-copy-cat/
 *
 * Add copy cat class to fields programmatically.
 */
// Update 123 to your form ID.
add_filter( 'gpcc_copy_cat_fields_123', function( $fields, $form ) {

	// Update 4 to the ID of the field that would have the Copy Cat Class
	$fields[4] = array(
		array(
			'source'       => 4,  // Update 4 to the ID of the source field.
			'target'       => 5,  // Update 5 to the ID of the target field.
			'sourceFormId' => $form['id'],
			'targetFormId' => $form['id'],
		),
	);

	return $fields;
}, 10, 2 );

Leave a Reply

Your email address will not be published. Required fields are marked *

  • Trouble installing this snippet? See our troubleshooting tips.
  • Need to include code? Create a gist and link to it in your comment.
  • Reporting a bug? Provide a URL where this issue can be recreated.

By commenting, I understand that I may receive emails related to Gravity Wiz and can unsubscribe at any time.