Dynamically Set Limit by User ID

Read the Walkthrough

Code

Filename: gpls-set-limit-by-user-id.php

<?php
/**
 * Gravity Perks // Limit Submissions // Dynamically Set Limit by User ID
 * https://gravitywiz.com/gravity-forms-limit-submissions/
 */
// Update "123" to your form ID.
add_filter( 'gpls_rule_groups_123', function ( $rule_groups ) {
	// Update "234" to your excepted user ID. Add additional user IDs separated by a comma.
	if ( in_array( get_current_user_id(), array( 234 ) ) ) {
		// Update "5" to your desired limit for excepted users.
		$rule_groups[0]->limit = 5;
	}
	return $rule_groups;
} );

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.