query_vars in plugin not working?

I have a problem writing a plugin for wordpress.
First, I register a new query_var and add a new rewrite rule:

function nng_users_query_vars( $vars ) {
    array_push( $vars, 'nng_users' );
    return $vars;
}
add_filter('query_vars', 'nng_users_query_vars');

function nng_users_rewrite_rules( $rules ) {
$newrules = array(
                        'benutzer/([^/]+)/?$' => 'index.php?pagename=nng_users&nng_users=$matches[1]'
                      );
$finalrules = $newrules + $rules;
    return $finalrules;
}
add_filter('rewrite_rules_array','nng_users_rewrite_rules');

This works perfectly, but I cannot grab any query_var from the plugin. Typing:

print_r( $wp_query->query_var );

or

echo $wp_query->query_var['some_var'];

does not show anything. But why? If I put the exact same thing into the function of my theme, it works. If I put it into a function and call this function in my theme, it works…
Background is the following: I want to create a custom user system and therefore I need to check my custom query var to e.g. logout or header-redirect.

Thanks in advance

1 Answer
1

Late answer, but for everybody else looking for it, this works:

http://codex.wordpress.org/Function_Reference/get_query_var

Leave a Comment