close
Cimatti Consulting

Most popular searches

WordPress Contact Forms API

Heads up! This page is available only in Italian

WordPress Contact Forms Plugin by Cimatti is developed as part of our Accua Marketing Platform. It includes Accua Form API and Accua Forms. Accua Form API allows the integration of the PHP Form Builder Class with WordPress. Accua Forms implements a visual interface for the creation and management of forms. For this reason actions and filters have the prefix “accua_form_” or “accua_forms_”.

Accua Forms filters and actions

To validate and do actions with the forms defined in the “WordPress Contact Form Plugin” you can use filters “accua_forms_validation” and “accua_forms_submission”

Filter accua_forms_validation

add_filter('accua_forms_validation', 'my_function_name', 10, 4);
function my_function_name($valid, $fid, $submittedData, $form){
  // Do your checks and set $my_validation_result as true or false
  return $valid && $my_validation_result;
}

$valid: the current result of validation, true if all tests are passed, false if an error occured
$fid: form id
$submittedData: array containing data submitted by the user
$form: the AccuaForm object. You should use $form->setFormError($errors, $element) to output an error message

Please note that this is a filter, so you have to return $valid even if your function does nothing, or you will break the validation process.

Filter accua_forms_submission

add_filter('accua_forms_submission', 'my_function_name', 10, 6);
function my_function_name($replace_map, $fid, $submittedData, $form, $_field_data, $_istance_data){
  // Execute your custom php code. Modify or add custom tokens in array $replace_map
  return $replace_map;
}

$replace_map: associative arrays of the tokens. You can modify or add values. You must return this array at the end. To avoid name collision, if you define custom tokens you should prefix with “__your_plugin_name_”.
$fid: the form id
$submittedData: data submitted by the user
$form: the form object
$_field_data: array that contains the data that defines the fields
$_istance_data: array that contains the settings of the istance of the fields

Action accua_forms_print_tokens

If you are a plugin developer, the main way to add functionalities to the “WordPress Contact Forms Plugin” is defining custom tokens and letting the user add them to messages. If you want to show a brief description of your tokens in the message settings pages, you can use the action “accua_form_print_tokens”.

add_action('accua_forms_print_tokens', 'my_function_name');
function my_function_name() {
  echo "List of my custom tokens";
}

Accua Form API and PHP Form Builder Class integration

The plugin defines the class “AccuaForm” that extends the “Form” class from PFBC. To create a new form you can use

$form = AccuaForm::create($formID);
$form->render(); //output html

This class works a little differently from PFBC. When an AccuaForm object is created, “accua_form_alter” action is called so the form can be defined adding fields, styles and validation functions.

The generated form is serialized and saved in an encrypted hidden field. When the form is submitted, the form object is unserialized from the submitted form, and integrity checks are done so the submitter can’t taint the serialized encrypted form. Serialized form is not saved on the server, so it will not waste server resource even if it will not be submitted.

When the form is submitted, validation functions are called. If the validation passes, submission functions are called.

Action accua_form_alter

add_action('accua_form_alter', 'my_function_name', 10, 2);
function my_function_name($formID, $form) {
  // do something on $form object
}

$formID: the form ID
$form: the AccuaForm object

Forms created with the interface have the prefix ‘__accua-form__’, so if you use one of these hooks you should check that IDs starts with ‘__accua-form__’

Filter accua_form_validate

add_filter('accua_form_validate', 'my_function_name', 10, 4);
function my_function_name($valid, $formID, $submittedData, $form){
  // Do your checks and set $my_validation_result as true or false
  return $valid && $my_validation_result;
}

$valid: the current result of validation, true if all tests are passed, false if an error occured
$formID: form id
$submittedData: data submitted by the user
$form: the AccuaForm object. You should use $form->setFormError($errors, $element) to output an error message

Please note that this is a filter, so you have to return $valid even if your function does nothing, or you will break the validation process.

Filter accua_form_submit

add_action('accua_form_submit', 'my_function_name', 10, 3);
function my_function_name($formID, $submittedData, $form){
  // Do your custom code
}

$fid: the form id
$submittedData: data submitted by the user
$form: the form object

Our skills

Industry
food
construction
editorial
electronics

manufacture
mechanical
medical
packaging
Craft
ceramic
food
fashion
Commerce
distributors
resellers
shops
Tourism
hotels
farmhouses
accommodation facilities
Professionals
consultants
professional studios

Siamo in Romagna, lavoriamo con tutto il mondo

Ravenna
Faenza
Lugo
Bagnacavallo
Castel Bolognese
Ravenna

Emilia Romagna
Forlì
Imola
Cesena
Rimini

Italia
Bologna
Milano
Ferrara
Firenze
Palermo
Roma
Torino

Worldwide
Canada
UK
USA

Cancel

Necessari

I cookie necessari sono i cookie tecnici cioè quelli il cui utilizzo non richiede il consenso dell’utente.

Questi cookie sono essenziali per consentire di navigare in un sito web e utilizzarne tutte le funzionalità. Senza questi cookie, che sono assolutamente necessari, un sito web non potrebbe fornire alcuni servizi o funzioni e la navigazione non sarebbe agevole e facile come dovrebbe essere. Un cookie di questo tipo viene inoltre utilizzato per memorizzare la decisione di un utente sull’utilizzo di cookie sul sito web.

I cookie tecnici sono essenziali e non possono essere disabilitati utilizzando questa funzionalità.
In generale comunque i cookie possono essere disattivati completamente nel proprio browser in qualsiasi istante.

Chiudi

Cancel

Statistiche

I cookie statistici vengono utilizzati per monitorare le performances del sito, per esempio per conoscere il numero di pagine visitate o il numero di utenti che hanno visualizzato una determinata sezione.

I cookie statistici utilizzati dal nostro sito si avvalgono di servizio di Google Analytics.

L’analisi di questi cookie genera dati statistici anonimi e aggregati senza riferimento alcuno all’identità dei navigatori del sito. Sono utili anche per valutare eventuali modifiche e miglioramenti da apportare al sito stesso.

Chiudi

Cancel

Targeting

I cookie di targeting sono cookie impostati da terze parti come YouTube, Facebook, Twitter.

Questi cookie tengono traccia del tuo comportamento come la riproduzione di video o quali tweet hai già visualizzato.

Se non viene dato il consenso a questi cookie, non sarà possibile guardare i video su questo sito web o utilizzare la funzionalità di condivisione sui social.

Questi cookie possono essere utilizzati dal fornitore di cookie per creare un profilo dei tuoi interessi e mostrarti pubblicità pertinenti su altri siti. Non memorizzano direttamente informazioni personali, ma si basano sull'identificazione univoca del browser e del dispositivo Internet.

Chiudi