Disable Limits for a Specific User Role

Read the Walkthrough

Code

Filename: gpls-disable-limits-for-specific-user-role.php

<?php
/**
 * Gravity Perks // GP Limit Submissions // Disable Limits for a Specific User Role
 * https://gravitywiz.com/documentaiton/gravity-forms-limit-submissions/
 */
// Update '123' to the ID of the Form.
add_filter( 'gpls_rule_groups_123', function( $rule_groups, $form_id ) {
	// Update to the slug of the role, i.e. administrator, editor, author, contributor, subscriber.
	$role_to_check = 'administrator';
	$user          = wp_get_current_user();
	if ( in_array( $role_to_check, (array) $user->roles ) ) {
		$rule_groups = array();
	}
	return $rule_groups;
}, 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.