Greyd Forms Actions

This document lists all action hooks available in the Greyd Forms plugin. Hooks are organized by their role in the form lifecycle. Most hooks are triggered by the plugin itself during form handling. A few hooks are utility hooks that developers can call manually inside their own extensions to log, abort, or complete form processing. See the Greyd Forms Actions Snippets for examples how to use the filters.

Core form lifecycle hooks

greyd_forms_action_before_entry

Runs before the form entry is saved to the database. Use this hook for preprocessing, additional validation, or modifying form data before storage.

Parameters:

  • array $form_data – Validated form data.
  • int $form_id – WP_Post ID of the form.
  • array $file_data – Uploaded files.
PHP
/**
 * Perform an action before the form is saved as entry.
 *
 * @action greyd_forms_action_before_entry
 *
 * @param array  $form_data    Validated form data.
 * @param int    $form_id      WP_Post ID of the form.
 * @param array  $file_data    Uploaded files.
 */
do_action( 'greyd_forms_action_before_entry', $form_data, $form_id, $file_data );

greyd_forms_action_after_entry

Runs after the entry is saved. Common uses: notifications, triggering integrations, or updating external systems.

Parameters:

  • array $form_data
  • int $form_id
  • int $entry_id
PHP
/**
 * Perform an action after the form is saved as entry.
 *
 * @action greyd_forms_action_after_entry
 *
 * @param array  $form_data    Validated form data.
 * @param int    $form_id      WP_Post ID of the form.
 * @param int    $entry_id     WP_Post ID of the entry.
 */
do_action( 'greyd_forms_action_after_entry', $form_data, $form_id, $entry_id );

greyd_forms_action_after_mails

Runs after default emails are sent, but before user opt-in verification.

Parameters: array $data, int $post_id, int $entry_id

PHP
/**
 * Perform an action after the mails were sent before the user
 * is verified.
 *
 * @action greyd_forms_action_after_mails
 *
 * If you want to call a function after the user is verified,
 * use the action @see greyd_forms_action_after_optin for this. Find
 * more details her: self::optin().
 *
 * @param array  $data      Validated form data.
 * @param int    $post_id   WP_Post ID of the form.
 * @param int    $entry_id  WP_Post ID of the entry.
 */
do_action( 'greyd_forms_action_after_mails', $form_data, $form_id, $entry_id );

greyd_forms_action_after_optin

Runs after a user completes the opt-in verification process.

Parameters: array $form_data, int $form_id, int $entry_id, array $entry_data

PHP
/**
 * Perform an action after the form was verified.
 *
 * This hook is a good way to trigger your own actions after the doi is verified.
 * That's especially usefull for custom API-calls.
 *
 * @action greyd_forms_action_after_optin
 *
 * @param array  $form_data    Validated form data.
 * @param int    $form_id      WP_Post ID of the form.
 * @param int    $entry_id     WP_Post ID of the entry.
 * @param array  $entry_data   Entire data of the entry.
 */
do_action( 'greyd_forms_action_after_optin', $form_data, $form_id, $entry_id, $entry_data );

greyd_forms_after_optout

Runs after a user opts out.

Parameters: int $entry_id

PHP
/**
 * Action to perform custom operations after a user opts out.
 * 
 * This action allows developers to hook into the opt-out process
 * to perform custom operations, API calls, or other actions
 * when a user withdraws their consent.
 * 
 * @action greyd_forms_after_optout
 * 
 * @param int $entry_id The entry ID of the user who opted out.
 * 
 * @return void
 */
do_action( 'greyd_forms_after_optout', $entry_id );

Utility hooks (developer-triggered)

These actions are manually triggered from your own code using do_action(). They allow you to log to the frontend console, abort processing with an error, or stop execution with a success message.

greyd_forms_log

Logs debug information to the browser console in the frontend. Developers can call this inside custom hooks or extensions to output data for debugging.

PHP
/**
 * Action to log debug information during form processing.
 * 
 * This action allows developers to hook into the form processing
 * to log debug information, raw form data, and other processing
 * details for debugging and monitoring purposes.
 * 
 * @action greyd_forms_log
 * 
 * @param mixed  $data        The data to be logged (can be any type).
 * @param string $description A description of what is being logged.
 * 
 * @return void
 */
do_action( 'greyd_forms_log', $data, 'raw form data' );

greyd_forms_error

Immediately ends processing and returns an error message to the frontend. The plugin calls wp_die() automatically after this hook.

PHP
/**
 * Action to handle form submission errors.
 * 
 * This action allows developers to hook into form error handling
 * to perform custom error processing, logging, or user notification
 * when form submissions fail validation or processing.
 * 
 * @action greyd_forms_error
 * 
 * @param string $message The error message describing what went wrong.
 * 
 * @return void
 */
do_action( 'greyd_forms_error', $message );

greyd_forms_success

Immediately ends processing and returns a success message to the frontend. The plugin calls wp_die() automatically after this hook.

PHP
/**
 * Action to handle successful form submissions.
 * 
 * This action allows developers to hook into successful form processing
 * to perform custom success handling, logging, or user notification
 * when forms are submitted and processed successfully.
 * 
 * @action greyd_forms_success
 * 
 * @param array $args Array containing the post_id and other success data.
 * 
 * @return void
 */
do_action( 'greyd_forms_success', array( 'post_id' => $post_id ) );

Deprecated action names

While deprecated actions still work, always prefer the new greyd_forms_ names in new development.

formhandler_after_optoutgreyd_forms_after_optout

formhandler_loggreyd_forms_log

formhandler_errorgreyd_forms_error

formhandler_successgreyd_forms_success

formhandler_before_entrygreyd_forms_action_before_entry

formhandler_after_entrygreyd_forms_action_after_entry

formhandler_after_mailsgreyd_forms_action_after_mails

formhandler_after_doigreyd_forms_action_after_optin