Documentation

Developer Hooks, Filters & JavaScript API

Technical guide to extending Diviniket WP Forms with PHP action hooks, filter hooks, and front-end JavaScript events.

DEVELOPER DOCUMENTATION

Developer Hooks, Actions & API Reference

Customize form lifecycle execution, hook into submission events, sanitize custom inputs, and integrate with external CRM systems using native WordPress hooks.

1. Official Shortcode Integration

Diviniket WP Forms can be embedded into any WordPress post, page, widget, or page builder template using the clean shortcode syntax:

[divismfo_form id="123"]

You can also execute the shortcode programmatically within your WordPress theme template files using PHP:

<?php echo do_shortcode('[divismfo_form id="123"]'); ?>

2. Core PHP Action Hooks

Tap into the submission lifecycle to trigger custom logic, send custom webhook requests, or update user meta:

  • divismfo_before_submission – Fires immediately before processing and validation begins. Useful for custom pre-submission checks.
  • divismfo_after_submission – Fires after a form has passed validation and entries are saved to the database. Receives $entry_id, $form_id, and $form_data arrays.
  • divismfo_entry_created – Fires right after an entry row is inserted into wp_divismfo_entries.

3. Custom Action Hook Example

add_action('divismfo_after_submission', 'custom_agency_lead_sync', 10, 3);
function custom_agency_lead_sync($entry_id, $form_id, $form_data) {
  if ($form_id === 12) {
    $email = sanitize_email($form_data['email']);
    $name = sanitize_text_field($form_data['name']);
    wp_remote_post('https://api.yourcrm.com/v1/leads', [
      'body' => json_encode(['email' => $email, 'name' => $name]),
      'headers' => ['Content-Type' => 'application/json']
    ]);
  }
}

4. Frontend JavaScript Events

Listen to client-side DOM events dispatched by Diviniket WP Forms for custom analytics tracking or modal triggers:

document.addEventListener('divismfo_form_success', function(e) {
  const formId = e.detail.formId;
  if (typeof gtag === 'function') {
    gtag('event', 'generate_lead', { form_id: formId });
  }
});

Need More Help?

Explore our active community, YouTube video walkthroughs, or get in touch with our support team.