Custom forms (REST hook)
If a site uses a hand-built form, a theme's built-in form or a plugin FormVigilant does not support yet, you can still monitor it by registering a small adapter. The connector discovers it, submits through it and verifies the notification like any other form.
When to use this
- A theme or agency framework ships its own contact form handler.
- The form posts to a custom REST route or
admin-post.phpaction. - A form plugin is not on the integrations list.
How it works
Adapters are PHP classes that extend FormVigilant_Adapter and are registered with the formvigilant_adapters filter. The connector calls discover() on every adapter during discovery and routes signed test requests to the adapter named in the request. The full method list is in the adapter contract.
add_filter( 'formvigilant_adapters', function ( array $adapters ) {
require_once __DIR__ . '/class-acme-contact-adapter.php';
$adapters['acme_contact'] = 'Acme_Contact_Adapter';
return $adapters;
} );
A minimal adapter
The adapter submits through the same function your form handler uses, so the real validation and wp_mail() call run.
class Acme_Contact_Adapter extends FormVigilant_Adapter {
public static function slug(): string { return 'acme_contact'; }
public static function is_active(): bool { return function_exists( 'acme_handle_contact' ); }
public function discover(): array {
return array( array(
'form_id' => 1,
'title' => 'Contact (theme)',
'fields' => array(
array( 'id' => 'name', 'type' => 'text', 'label' => 'Name', 'required' => true ),
array( 'id' => 'email', 'type' => 'email', 'label' => 'Email', 'required' => true ),
array( 'id' => 'message', 'type' => 'textarea', 'label' => 'Message', 'required' => true ),
),
'recipients' => array( get_option( 'admin_email' ) ),
'capabilities' => $this->capabilities( 1 ),
) );
}
public function submit( int $form_id, string $marker, array $overrides = array() ): array {
$result = acme_handle_contact( array(
'name' => 'FormVigilant Test',
'email' => 'test+' . $marker . '@formvigilant.com',
'message' => '[FormVigilant test] Automated delivery check ' . $marker . '. Please ignore.',
) );
return array( 'ok' => ! is_wp_error( $result ), 'errors' => is_wp_error( $result ) ? $result->get_error_messages() : array(), 'entry_id' => null );
}
public function find_entry( int $form_id, string $marker ): ?int { return null; }
public function delete_entry( int $entry_id ): bool { return true; }
public function suppress_side_effects(): void { /* remove CRM hooks for this request */ }
public function capabilities( int $form_id ): array {
return array( 'levels' => array( 1, 3, 4 ), 'side_effects' => 'unknown', 'testable' => true, 'unsupported' => array() );
}
}
This adapter has no entry store, so it reports levels 1, 3 and 4, and side_effects: "unknown" until you implement suppress_side_effects(). FormVigilant asks you to confirm before monitoring a form with unknown side effects.
Test values
Always use the fixed public values above and include the marker. The connector's mail hooks only recognise messages that contain an active marker; everything else on the site is left alone.
Shipping it
Keep the adapter in a must-use plugin or your site plugin, not in the theme, so a theme switch does not silently remove it. Adapters must not import each other, so each can later move into its own add-on plugin.