Skip to content

Added support for generic implementation (very simple)#168

Open
LU-386 wants to merge 7 commits intoFriendlyCaptcha:mainfrom
LU-386:main
Open

Added support for generic implementation (very simple)#168
LU-386 wants to merge 7 commits intoFriendlyCaptcha:mainfrom
LU-386:main

Conversation

@LU-386
Copy link
Copy Markdown

@LU-386 LU-386 commented Apr 14, 2026

Hey,

i was looking for documentation to integrate FriendlyCaptcha into a custom plugin and found basically nothing.

My unknown friend Steve was looking for something like this as well.

I grabbed most of the code from #167 for simplicity. Thanks to @RealZendor for the great base.

Implementation would be made in two simple steps after enabling the option in the settings.

Use the filter 'fch_captcha_append_widget' on your form or an empty string and print it:

$html = apply_filters( 'fch_captcha_append_widget', '' );
echo $html;

Use the filter 'fch_captcha_validation' before handling your inputs and get a bool (true = human, false = bot / missing solution):

$solution = sanitize_text_field($_POST["frc-captcha-solution"]);
$verified = apply_filters( 'fch_captcha_validation', $solution, true );

Let me know if you are looking to merge this or not.

Thanks for the great software btw!

@merlinfuchs merlinfuchs self-requested a review April 15, 2026 13:17
@merlinfuchs
Copy link
Copy Markdown
Member

Thanks for the PR! I think this is a great idea :)

I wonder if we even need to register this as an integration in core.php and expose it as an option in the plugin settings? Maybe the filters can just always be there?

Comment thread friendly-captcha/includes/core.php Outdated

public static $integrations = array(
array(
public static $integrations = [
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These appear to be mostly formatting changes. Could you remove them so we can only merge the actual changes?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done, thanks for pointing out!

Comment thread friendly-captcha/modules/generic_integration/generic_integration.php Outdated
Comment thread friendly-captcha/modules/generic_integration/generic_integration.php Outdated
return false;
}

$verification = frcaptcha_verify_captcha_solution(
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess other plugins could also just call frcaptcha_verify_captcha_solution directly right? I'm not a Wordpress expert so I wonder what the benefit of the additional filter is 🤔

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The filter name(s) must correspond to the filter name(s) in the FC module file. So in theory, it should be possible to have a generic module with filter names that the actual WP forms use.
However, I remember that I first tried to use the html-forms module for my purposes but it didn't work (may be I did a mistake).
Second:
All supported form plugins are listed in the core.php file like this:

array(
            "name" => "HTML Forms",
            "slug" => 'html_forms',
            "entry" => "html-forms/html-forms.php",
            "plugins" => array("html-forms/html-forms.php"),
            "settings_description" => "Enable Friendly Captcha for <a href=\"https://wordpress.org/plugins/html-forms/\" target=\"_blank\">HTML Forms</a>.",
        ),

That means there are hardcoded plugin names and paths, anyway (entry, plugins). So it makes no difference if we have custom filter names or not (I guess) since every single form plugin that we want to support needs it's own module file.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really wanted to keep it simple and version agnostic to implement.

If there is something additional to be handled in the future, it can just be added into the filter without affecting anything else by changing frcaptcha_verify_captcha_solution.

@merlinfuchs merlinfuchs self-assigned this Apr 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants