{"id":28562532,"url":"https://github.com/matt-west/craft-recaptcha","last_synced_at":"2025-06-10T12:09:54.109Z","repository":{"id":30649844,"uuid":"125618212","full_name":"matt-west/craft-recaptcha","owner":"matt-west","description":"Integrate Google’s reCAPTCHA into your web forms.","archived":false,"fork":false,"pushed_at":"2025-01-21T19:49:32.000Z","size":166,"stargazers_count":19,"open_issues_count":6,"forks_count":17,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-21T02:43:54.903Z","etag":null,"topics":["craft-plugin","craftcms","craftcms-plugin"],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/matt-west.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2018-03-17T10:25:55.000Z","updated_at":"2024-12-24T15:56:42.000Z","dependencies_parsed_at":"2024-06-18T21:35:10.342Z","dependency_job_id":"77864e09-3040-4ff9-8e68-be7368ee1fec","html_url":"https://github.com/matt-west/craft-recaptcha","commit_stats":{"total_commits":49,"total_committers":15,"mean_commits":"3.2666666666666666","dds":0.6938775510204082,"last_synced_commit":"d95e16a559899dca16afd50ecb88452569ecf216"},"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-west%2Fcraft-recaptcha","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-west%2Fcraft-recaptcha/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-west%2Fcraft-recaptcha/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-west%2Fcraft-recaptcha/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matt-west","download_url":"https://codeload.github.com/matt-west/craft-recaptcha/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matt-west%2Fcraft-recaptcha/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259072981,"owners_count":22801089,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["craft-plugin","craftcms","craftcms-plugin"],"created_at":"2025-06-10T12:09:52.971Z","updated_at":"2025-06-10T12:09:54.083Z","avatar_url":"https://github.com/matt-west.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Craft reCAPTCHA plugin for Craft CMS 4.x\n\nIntegrate Google’s reCAPTCHA into your forms.\nIncludes support for the CraftCMS [Contact Form](https://github.com/craftcms/contact-form) plugin.\n\n## Requirements\n\nThis plugin requires Craft CMS 5 or later.\n\n**This plugin supports reCAPTCHA v2 only.**\n\n## Installation\n\nTo install the plugin, follow these instructions.\n\n1. Open your terminal and go to your Craft project:\n\n        cd /path/to/project\n\n2. Then tell Composer to load the plugin:\n\n        composer require matt-west/craft-recaptcha\n\n3. In the Control Panel, go to Settings → Plugins and click the “Install” button for Craft reCAPTCHA.\n\n## Configuring Craft reCAPTCHA\n\n1. [Sign up for reCAPTCHA API key](https://www.google.com/recaptcha/admin).\n2. Open the Craft admin and go to Settings → Plugins → Craft reCAPTCHA → Settings.\n3. Add your `site key` and `secret key`, then save.\n4. Add the reCAPTCHA template tag to your forms. (see next section)\n\nIf you’re using the CraftCMS [Contact Form](https://github.com/craftcms/contact-form) plugin, everything is already set up for you.\n\n### Verify the reCAPTCHA\n\nTo verify the reCAPTCHA is valid, pass the reCAPTCHA response from the `g-recaptcha-response` param to the `verify()` method on `CraftRecaptcha::$plugin-\u003ecraftRecaptchaService`.\n\n```php\n// Get the reCAPTCHA response code to validate.\n$captcha = Craft::$app-\u003egetRequest()-\u003egetParam('g-recaptcha-response');\n\n// Pass the response code to the verification service.\n$validates = CraftRecaptcha::$plugin-\u003ecraftRecaptchaService-\u003everify($captcha);\n\nif ($validates) {\n  // All good! the reCAPTCHA is valid.\n} else {\n  // The reCAPTCHA is invalid.\n}\n```\n\nOr alternatively, use the in-built verification controller action to verify the request before forwarding it on to the intended action.\n\nFor example, the following fields would verify the reCAPTCHA and then pass the request to the login controller action:\n\n```twig\n\u003cinput type=\"hidden\" name=\"action\" value=\"recaptcha/recaptcha/verify-submission\"\u003e\n\u003cinput type=\"hidden\" name=\"verified-action\" value=\"users/login\"\u003e\n{{ craft.recaptcha.render() }}\n```\n\nSet the `action` field to be `recaptcha/recaptcha/verify-submission` and the `verified-action` field to be the intended controller action you want to trigger. This will forward all other fields and parameters to the intended controller action.\n\n### Automated testing and reCAPTCHA\n\nIf you need to run automated tests against your forms use the following keys. Verification requests using these credentials will always pass.\n\nSite key: `6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI`\nSecret key: `6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe`\n\n[Documentation](https://developers.google.com/recaptcha/docs/faq#id-like-to-run-automated-tests-with-recaptcha-v2-what-should-i-do)\n\n## Using Craft reCAPTCHA\n\nAdd the following tag to your form where you’d like the reCAPTCHA to be displayed.\n\n```twig\n{{ craft.recaptcha.render() }}\n```\n\nRender parameters [per the documentation](https://developers.google.com/recaptcha/docs/display#render_param) are injectable to the `render()` function, e.g.\n\n```twig\n{{ craft.recaptcha.render({\n  theme: 'dark',\n  size: 'compact'\n}) }}\n```\n\nYou can also create the reCAPTCHA element yourself using the `sitekey` template variable. This is especially useful for implementing invisible recaptcha.\n\n```twig\n\u003cdiv class=\"g-recaptcha\"\n      data-sitekey=\"{{ craft.recaptcha.sitekey }}\"\n      data-callback=\"onSubmit\"\n      data-size=\"invisible\"\u003e\n\u003c/div\u003e\n```\n\n---\n\nBrought to you by [Matt West](https://mattwest.io)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatt-west%2Fcraft-recaptcha","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatt-west%2Fcraft-recaptcha","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatt-west%2Fcraft-recaptcha/lists"}