Only Allow Some Rule Types

Code

Filename: gpls-only-allow-some-rule-types.php

<?php
/**
 * Gravity Perks // Limit Submissions // Only Allow Some Rule Types
 * https://gravitywiz.com/documentation/gravity-forms-limit-submissions/
 */
add_filter( 'gpls_rule_type_choices', function( $choices ) {

	// Supports "ip", "user", "embed_url", "role", "value".
	$allowed_rule_types = array( 'ip', 'user', 'role' );
	$filtered_choices   = array();

	foreach ( $choices as $choice ) {
		if ( in_array( $choice['value'], $allowed_rule_types ) ) {
			$filtered_choices[] = $choice;
		}
	}

	return $filtered_choices;
} );

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.