gpls_rule_type_choices

  1. Description
  2. Usage
  3. Parameters
  4. Examples
    1. Only allow some rule types.
  5. Since

Description

Filter the types of rules available for selection when configuring Limit Submission feeds.

Usage

add_filter( 'gpls_rule_type_choices', 'my_custom_function' );

Parameters

  • choices array

    An array of rule types (e.g. IP, User, Embed URL, Role, Field Value).

Examples

Only allow some rule types.

<?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;
} );

Since

This filter is available since Gravity Forms Limit Submissions 1.0.8.