Add reCAPTCHA to Shortcode

  • Register reCAPTCHA
  • Download recaptchalib.php and save in /plugin-maker/project/plugins/assets/your_plugin/includes/
  • Then copy file shortcode do want to edit /wp-content/plugins/your_plugin/includes/xxx_shorcodes.xxxx.inc.php to /plugin-maker/project/plugins/assets/your_plugin/includes/xxx_shorcodes.xxxx.inc.php
  • // your secret key $secret = $this->options["recaptcha_sitekey"]; // empty response $response = null; // check secret key $reCaptcha = new ReCaptcha($secret); if ($_POST["g-recaptcha-response"]) { $response = $reCaptcha->verifyResponse( $_SERVER["REMOTE_ADDR"], $_POST["g-recaptcha-response"] ); } if ($response != null && $response->success) { echo "Hi, thanks for submitting the form!"; } else { }