Create an Extra Entry if Checkbox is Checked

🧪

Experimental Snippet

This snippet was discovered in the wizard’s chaotic laboratory — an unpolished experiment, conjured to solve a niche challenge. Use at your own risk.

Create an additional entry identical to the first if a specified checkbox is checked.

Instructions

See “Where do I put snippets?” in our documentation for installation instructions.

Code

Filename: gw-create-extra-entry.php

<?php
/**
 * Gravity Wiz // Gravity Forms // Create an Extra Entry if Checkbox is Checked
 * https://gravitywiz.com/
 *
 * Experimental Snippet 🧪
 *
 * Create an additional entry identical to the first if a specified checkbox is checked.
 *
 * @see https://stackoverflow.com/a/69497108/227711
 */
// Update "123" to your form ID.
add_filter( 'gform_after_submission_123', function( $entry ) {
	// Update "4" to your Checkbox field ID. Assuming this is a single checkbox field, leave the "1" as it will target the first checkbox.
	if ( $entry['4.1'] ) {
		GFAPI::add_entry( $entry );
	}
}, 10 );

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.