0

i am trying to limit a Gravity Form in my WordPress project by a custom field.
This field, which is an ACF field like others on the same page, only calls a number. I am trying to overwrite the field "limitEntriesCount" which is a gravity-forms setting in the form itself.

I have tried the following code, with some help of a member of Gravity Forms:

    // Change limit entries by custom field.
    add_filter( 'gform_pre_render_1', 'set_entry_limit' );
    add_filter( 'gform_pre_validation_1', 'set_entry_limit' );
    add_filter( 'gform_pre_submission_filter_1', 'set_entry_limit' );
    add_filter( 'gform_admin_pre_render_1', 'set_entry_limit' );

    function set_entry_limit( $form ) {
      $eventTickets = get_field('event_tickets');
        global $post;
        // modify the form object here
        $limit = $post->$eventTickets;
        $form['limitEntries'] = 1; // set to true
        $form['limitEntriesCount'] = $limit;
        return $form;
    }

But it's just not working. I was hoping one of you guys have done this before and could help me out.

Thanks in advance!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.