Forms & Popups

How do I create a form that only allows a certain number of submissions?

With the following code snippet you can easily use GREYD.Forms to create a form that only allows a limited number of form submissions and displays a corresponding info message. Please be aware of the comments in the snippet as the code needs to be adapted individually.

if ( ! defined( 'COUNTER_FORM_ID' ) ) {

/**

* Replace this with the ID of your form.

*/

define( 'COUNTER_FORM_ID', 1 );

}

if ( ! defined( 'MAX_FORM_COUNT' ) ) {

/**

* Define the maximum number of entries.

*/

define( 'MAX_FORM_COUNT', 100 );

}

/**

* Handle the form submission.

*

* @param int $post_id The ID of the form.

* @param array $form_data The form data.

*/

function handle_custom_counter_form( $post_id, $form_data ) {

// Check if the form is the one we want to handle.

if ( $post_id != COUNTER_FORM_ID ) return;

// Get the current counter value.

$counter = intval( get_option( 'my_custom_counter', 0 ) );

// The maximum number of entries has been reached.

if ( $counter >= MAX_FORM_COUNT ) {

do_action(

'formhandler_error',

// The error message.

__( 'The maximum number of entries has been reached.', 'my_textdomain' )

);

return;

}

$counter++;

update_option( 'my_custom_counter', $counter );

// debug message

// remove this line in production

do_action('formhandler_error', 'counter is now: ' . $counter);

}

add_action( 'formhandler_after_entry', 'handle_custom_counter_form', 5, 3);

Related articles & tutorials

Where do I find the form ID?

To use the form ID for example in the Conditional Content Block, simply open the corresponding form. You will now find the form ID at the top in the URL, e.g. "post=17967"


Forms & Popups

Is it possible to have conditional follow-up actions in forms?

Imagine a contact form on a corporate website that triggers an admin notification to different departments (e.g. HR, marketing, sales) depending on the user's entries? Or a lead form with different product categories that automatically notifies the responsible sales employee? This is actually possible with Greyd.Forms. Here's how: As an example we are going to […]


Forms & Popups

What do I do when there is an error message in the forms backend?

GREYD.Forms informs you in various ways should anything go wrong with a form – e.g. if an interface is not working as it is supposed to or if an email could not be sent. You will see the respective error message in the form entry and – depending from your settings – also as an […]


Forms & Popups

How can I reset forms statistics?

While there is not yet a native option to reset forms statistics, it is still very easy to reset them manually with GREYD.Hub:Open the database tab and search for the tables of the respective website. You should find a table calledwp_greyd_forms_interactions or similar.Select it, scroll down and click on "delete table". Your form stats should then […]


Forms & Popups

How do I create a form that only allows a certain number of submissions?

With the following code snippet you can easily use GREYD.Forms to create a form that only allows a limited number of form submissions and displays a corresponding info message. Please be aware of the comments in the snippet as the code needs to be adapted individually.if ( ! defined( 'COUNTER_FORM_ID' ) ) { /** * […]


Forms & Popups

An error message appears when submitting a form in the frontend.

If an error message appears on the frontend when filling out a form, you may receive an admin notification that the validation of a WordPress NONCE failed.NONCE is a WordPress security token that is also integrated into GREYD.Forms. NONCEs are used to protect against abuse and malware. If you receive such a notification, it means […]


Forms & Popups

Forms & Popups

How to create quiz & live surveys

In this video, we are going to show you how to create interactive gamification elements in Greyd.Forms and add for example a quizz or survey with live feedback to your forms.

Forms & Popups

How do I use input fields?

Input fields are used wherever you want the user to enter something. In this video, we will show you how to set up fields for name, address or other inputs and which settings you can make.

Forms & Popups

What are the basic settings in Greyd.Forms?

Learn how to deposit a general privacy text for your forms and how to protect them against bots & malware. The video also shows you how to prevent your form mails from ending up in the spam folder and how to connect Greyd.Forms with your tools.

Forms & Popups

How can I make fields dependent from each other?

The conditional container block allows you to create dependencies between fields. Define, which fields should open after the user has chosen option A or B. Decide, if certain questions should be skipped depending on the user's entries.Learn here, how easy it is to create dependencies in Greyd.Forms.

Forms & Popups

How do I use image panels?

Image panels are a very good way to make your form more stylish. Instead of simple selection fields, show your user clickable image panels. This tutorial shows you the abundant, yet simple settings of the image panel block.

Forms & Popups

How do I use dropdown fields?

Allow your user to select from a dropdown list with the dropdown block. This video shows you which settings you can make.

Forms & Popups

How do I use radio buttons?

Similar to checkboxes, radio buttons are used to make a user select one of several options. Learn here how to use radio buttons.

Forms & Popups

How do I create a multistep form?

Especially for longer forms it may be useful to build your form with several steps. With next/back buttons users can navigate between the levels of your forms. Learn here how to easily create a multistep form with Greyd.Forms.

Forms & Popups

How do I create a contact form?

In this video, we are going to show you which widgets you can use to create a simple contact form. You will also learn how to set up e-mail notifications and integrate double opt-in for GDPR-compliant forms.

Forms & Popups

Which data can I find on form entries in the backend?

The Greyd.Forms backend shows you all form entries including status. You will also find detailed statistics to analyze your forms without an analytics tool and, of course, GDPR-compliant. This video also shows you how to delete form entries automatically.

Forms & Popups

How do I design checkboxes?

A checkbox can be used to accept terms & conditions or privacy regulations, but also to select options. Our checkbox tutorial shows you everything you need to know about Greyd.Forms’ checkbox block.

Forms & Popups

How do I use upload fields?

You want your user to upload a file to your form? No problem! Learn here which options Greyd.Forms offers to easily integrate an upload field.