swte

Whitelist FB UA

May 4th, 2026
101
0
Never
4
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.53 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Plugin Name: MH Captcha - Facebook UA whitelist
  4.  * Description: Trust requests from Facebook link preview scrapers (Facebot / facebookexternalhit).
  5.  */
  6.  
  7. add_filter('mhcaptcha/is_trustable_request', function ($is_trustable) {
  8.     $ua = $_SERVER['HTTP_USER_AGENT'] ?? '';
  9.  
  10.     // Facebook scrapers typically use these user agents.
  11.     if ($ua && (
  12.         stripos($ua, 'facebookexternalhit') !== false ||
  13.         stripos($ua, 'Facebot') !== false
  14.     )) {
  15.         return true;
  16.     }
  17.  
  18.     return $is_trustable;
  19. });
Advertisement
Comments
  • User was banned
  • User was banned
  • User was banned
  • User was banned
Add Comment
Please, Sign In to add comment