Manage forms

How to manage forms

Enabling the form builder

First, you need to enable the form builder to use it.

Go to the Settings page and find the "Content settings" section, enable the form builder, and you are good to go.

Create the first form

To create a new template, navigate to the form list.

Click on the Create form button. A modal appears:

Showing three fields:

  • Name - The form name

  • Label - The form label

  • Action - Choose the action between Ajax, Custom, Post Management or PHP

  • Successful outcome message - In case of success, this message will be displayed in a green alert

  • Redirect after submission - In case of success, redirect to a specific page. Leave black for redirect on the same page

Form action

The form action determines its behavior.

Depending on the action, a few different fields will appear.

Ajax action

This action allows running a custom AJAX script to handle submitted form data.

The path of invoked AJAX action is required.

Your custom code is directly executed in the response of the AJAX call.

The data variable contains the Promise response value:

// data contains the Promise response
console.log(data);

and can be directly used in your JS code.

Custom action

This action allows setting a custom form action.

You must also choose the form method (POST or GET).

Post Management action

This action allows saving ACPT meta fields.

There is no need for further configurations.

PHP action

This action allows running a custom PHP script to handle submitted form data.

ACPT rewrites $_POST and $_FILES global super variables, to be used in your script:

<?php
// $_POST and $_FILES store form data already sanitized
// by HandleFormSubmissionCommand class
$data = $_POST;
$files = $_FILES;

In the example code,$data now contains an array of form fields' sanitized values.

Meta fields mapping

Whatever action you choose, you need to specify the list of meta fields (coming from a group already saved) to populate the form builder.

You can choose between:

  • a Custom Post Type

  • a Taxonomy

  • an Option page

  • all users

The list of associated meta fields will appear immediately after.

You can select what fields you want to use in your form.

Optionally, you can specify the form target: a specific post, taxonomy, page, or user.

Once you are done, click on Save.

Now, locate the Manage link on the forms table list to open the form builder.

Submission limits

You can set one or more submission rules. The possible rules are:

  • Anonymous user

  • Logged users

  • Specific user

  • User role

For every rule, you need to specify the submission limit.

CSS Variables

ACPT forms fully support CSS variables.

If you want to change the default CSS variables' values, expand the variable table and set a value for dark and light color schemes.

Use the form on your website

After a form is created, a shortcode is automatically generated.

For example:

[acpt_form id="2db51086"]

Use this shortcode to display the form where you need it.

Last updated