Lighthouse – CAPTCHA, Akismet Integration and Spam Registration Hooks

on in Blog, WordPress
Last modified on

I am excited to announce the latest release of Lighthouse in 2024, the WordPress performance tuning plugin that removes a lot of default WordPress behaviour and improves your website’s speed, performance, and security.

Lighthouse 3.9.10 introduces some new features and enhancements that will make your website even faster and more secure. Here are some of the highlights:

CAPTCHA Feature

Lighthouse now offers a CAPTCHA feature that you can enable to protect your website from spam and bots. CAPTCHA is a simple test that verifies that a user is human and not a malicious program. The CAPTCHA can be applied to various forms on your website, such as login, registration, or password reset.

Removed print_emoji_styles Filter

Lighthouse has removed the print_emoji_styles filter, which was deprecated in WordPress 6.4.0. This filter was used to add emoji support to older browsers, but it also added unnecessary code and requests to your website.

Akismet Integration

Lighthouse now integrates with Akismet, the popular anti-spam service for WordPress. Akismet automatically checks and filters out spam registrations on your website, adding to the 4P blacklist and the custom, integrated blacklist. Lighthouse allows you to enable or disable Akismet integration with a simple toggle.

User Actions for Spam

A new user action now allows you to mark email domains as spam. For example, if a spam registration occurs, and the email is spammer@some-funky-domain.info, you can mark the some-funky-domain.info as spam.

Webhooks for Spam Registrations

Lighthouse also adds a new feature that allows you to set up webhooks for spam registrations. Webhooks are a way of sending data from one application to another when a certain event occurs. For example, you can use webhooks to send an email notification, or trigger a custom action, whenever a spam registration is detected on your website. Lighthouse lets you hook into the lighthouse_spam_check_result action, where you can specify the URL and the data format of your webhook.

Here is an example implementation (this would go inside another plugin, or theme):

add_filter( 'lighthouse_spam_check_result', 'my_send_spam_notification', 10, 4 );

/**
 * Sends an email notification when a spam or legitimate registration is detected.
 *
 * @param bool   $is_spam   Whether the registration is spam or not.
 * @param string $username  The username of the registrant.
 * @param string $email     The email address of the registrant.
 * @param string $method    The method used to detect spam (e.g. CAPTCHA, Akismet, etc.).
 * @return bool             The original value of $is_spam.
 */
function my_send_spam_notification( $is_spam, $username, $email, $method ) {
    if ( $is_spam ) {
        $to = 'user@example.com';
        $subject = 'Spam Registration Detected';
        $message = "A spam registration was detected. Username: $username, Email: $email, Method: $method";
        wp_mail( $to, $subject, $message );
    } else {
        $to = 'user@example.com';
        $subject = 'Legitimate Registration Detected';
        $message = "A new registration was detected. Username: $username, Email: $email, Method: $method";
        wp_mail( $to, $subject, $message );
    }
}

Related posts