MASPIK Developer Hooks
MASPIK now includes its first developer hooks, giving developers more control and flexibility.
With these hooks, you can disable spam checks for specific forms or conditions.
Currently supported (from version 2.5.5 and above):
- Contact Form 7
- Elementor Forms
- WordPress Comments
1. Contact Form 7 Hook
Filter name: maspik_disable_cf7_spam_check
This filter allows you to disable MASPIK spam check for specific CF7 forms by ID.
Parameters:
- $disable (bool) — Whether to disable spam check (default: false).
- $form_id (int) — The ID of the CF7 form.
Usage Examples:
// Disable spam check for a single form
add_filter('maspik_disable_cf7_spam_check', function($disable, $form_id) {
if ($form_id === 123) {
return true; // Disable spam check for form ID 123
}
return $disable;
}, 10, 2);
// Disable spam check for multiple forms
add_filter('maspik_disable_cf7_spam_check', function($disable, $form_id) {
$excluded_form_ids = [123, 456, 789];
if (in_array($form_id, $excluded_form_ids)) {
return true;
}
return $disable;
}, 10, 2);
// Disable spam check for logged-in administrators
add_filter('maspik_disable_cf7_spam_check', function($disable, $form_id) {
if (is_user_logged_in() && current_user_can('administrator')) {
return true;
}
return $disable;
}, 10, 2);
2. Elementor Forms Hook
Filter name: maspik_disable_elementor_spam_check
This filter allows you to disable spam checks for specific Elementor forms by name.
Parameters:
- $disable (bool) — Whether to disable spam check (default: false).
- $form_name (string) — Name of the Elementor form.
- $record (object) — Elementor form record object.
Usage Examples:
// Disable spam check for a specific form by name
add_filter('maspik_disable_elementor_spam_check', function($disable, $form_name, $record) {
if ($form_name === 'MY_CONTACT_FORM') {
return true; // Disable spam check
}
return $disable;
}, 10, 3);
// Disable spam check for multiple forms
add_filter('maspik_disable_elementor_spam_check', function($disable, $form_name, $record) {
$excluded_forms = ['MY_FORM_1', 'MY_FORM_2', 'ADMIN_TEST_FORM'];
if (in_array($form_name, $excluded_forms)) {
return true;
}
return $disable;
}, 10, 3);
// Disable spam check for logged-in administrators
add_filter('maspik_disable_elementor_spam_check', function($disable, $form_name, $record) {
if (is_user_logged_in() && current_user_can('administrator')) {
return true;
}
return $disable;
}, 10, 3);
3. WordPress Comments Hook
Filter name: maspik_disable_wp_comments_spam_check
This filter allows you to disable MASPIK spam check for WordPress comments, based on post ID or other conditions.
Parameters:
- $disable (bool) — Whether to disable spam check (default: false).
- $post_id (int) — ID of the post where the comment is submitted.
- $data (array) — Comment data array.
Usage Examples:
// Disable spam check for a specific post
add_filter('maspik_disable_wp_comments_spam_check', function($disable, $post_id, $data) {
if ($post_id === 123) {
return true; // Disable spam check on post ID 123
}
return $disable;
}, 10, 3);
// Disable spam check for multiple posts
add_filter('maspik_disable_wp_comments_spam_check', function($disable, $post_id, $data) {
$excluded_post_ids = [123, 456, 789];
if (in_array($post_id, $excluded_post_ids)) {
return true;
}
return $disable;
}, 10, 3);
// Disable spam check for logged-in administrators
add_filter('maspik_disable_wp_comments_spam_check', function($disable, $post_id, $data) {
if (is_user_logged_in() && current_user_can('administrator')) {
return true;
}
return $disable;
}, 10, 3);
✅ Tip for developers:
Place these snippets in your theme’s functions.php file or in a custom plugin.