I'm toying with a honeypot to catch form spammers. I've hidden a link to a non-existent page in the footer. What I'm attempting to do now is, when they visit that link, to display a form that looks to be a normal WP page for that site. What I have below does that with one exception. I'm getting a lot CORS errors No 'Access-Control-Allow-Origin' errors. So apparently I'm missing something in the wp loading sequence to display a page. Pages loaded the normal way on the site do not display this CORS error.
I've tried adding
header("Access-Control-Allow-Origin: *");
without success.
Any ideas?
add_action('parse_request', array($this, 'Check_Incoming'));
public function Check_Incoming() {
global $wp;
$current_url = add_query_arg($wp->query_string, '', home_url($wp->request));
$parsed = parse_url($current_url);
if ($parsed['path'] == '/myhiddenform') {
include_once 'My_Request.php';
$form = new Form_Show();
get_header();
wp_head();
$form->show_form();
get_footer();
wp_footer();
die();
}
}
Here's the exact errors I'm getting. All seem to be trying to load fontawesome webfonts..
Failed to load resource: net::ERR_FAILED fontawesome-webfont.ttf:1
Access to font at 'https://example.com/wp-content/themes/melos/lib/extentions/font-awesome/fonts/fontawesome-webfont.ttf?v=4.7.0' from origin 'https://www.example.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
https://example.com/myhiddenform
? Andwp_head()
is normally called in the header template, so it's kinda weird you're doingget_header(); wp_head();
.. same goes with theget_footer(); wp_footer();
..if ($parsed['path'] == '/myhiddenform') { echo 'test'; die(); }
, are you still getting the same errors? Have you tried clearing your caches and disabling caching just for a while?