ReCAPTCHA guard for the Uniform plugin

v1.0.0 2017-11-14 05:08 UTC

This package is auto-updated.

Last update: 2021-09-15 21:05:29 UTC


An extension to the Kirby 2 plugin Uniform (v3) to add the Google reCAPTCHA guard.


Kirby CLI

Get the Kirby CLI and run kirby plugin:install fetzi/kirby-uniform-recaptcha.


Download the repository and extract it to site/plugins/uniform-recaptcha.


Run composer require fetzi/kirby-uniform-recaptcha. Then add the second require to the index.php like this:

// load kirby
require(__DIR__ . DS . 'kirby' . DS . 'bootstrap.php');
require 'vendor'.DS.'autoload.php';

Be sure to include the new vendor directory in your deployment.


Define the mandatory config settings:

  1. c::set('uniform-recaptcha-sitekey', 'YOUR RECAPTCHA SITEKEY');
  2. c::set('uniform-recaptcha-secret', 'YOUR RECAPTCHA SECRET');


You can use the recaptchaGuard in your controllers form definition:

$form = new Form(/* ... */);

if (r::is('POST')) {
        ->emailAction(/* ... */);

To embed the recaptcha field into your template simply call <?php echo recaptcha_field(); ?>

The plugin needs the recaptcha Javascript File provided by Google. You can either include the JavaScript file directly into your page or by calling the method embed_recaptcha_js() in your template.


<form action="<?php echo $page->url()?>" method="post">
    <label for="name" class="required">Name</label>
    <input<?php if ($form->error('name')): ?> class="erroneous"<?php endif; ?> name="name" type="text" value="<?php echo $form->old('name') ?>">

    <!-- ... -->

    <?php echo csrf_field() ?>
    <?php echo recaptcha_field() ?>
    <input type="submit" value="Submit">
<?php echo embed_recaptcha_js(); ?>


Johannes Pichler https://johannespichler.com