WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to add some security/acccess prevention to my site via the functions.php. However whenever I try to add through functions.php (instead of as a plugin, which I've done in the past) it fails (always returns false). For example:

add_action("parse_query", checkaccess());  // in functions.php


function checkaccess() {
    $allowAccess = false;


        echo 'whatup'; //do something here


even if i try something basic - eg global $wp_query; var_dump($wp_query); I can't get the query var, its all NULL. Any advice? Is there some kind of walled sandbox the fuctions.php file operates from that it can't get any of these?

share|improve this question
up vote 1 down vote accepted

Your add_action should be:

add_action( "parse_query", "checkaccess" );
share|improve this answer
ah! in quotes rather than calling a function directly, right? – dama_do_bling Apr 30 '12 at 17:11
@dama_do_bling correct, callbacks should be string-formatted. – Milo Apr 30 '12 at 17:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.