Last active
August 29, 2015 14:13
-
-
Save rustyeddy/f43303114d077b676918 to your computer and use it in GitHub Desktop.
Properly Handling URL requests in WordPress
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* We need to add our query variables | |
*/ | |
add_filter( 'query_vars', 'mb_register_variables' ); | |
function mb_register_variables( $qv ) | |
{ | |
$qv[] = 'Badge'; | |
$qv[] = 'Username'; | |
$qv[] = 'Password'; | |
return $qv; | |
} | |
/* | |
* Now respond to the query variables | |
*/ | |
add_action( 'parse_request', 'mb_parse_request' ); | |
function mb_parse_request( $wp ) | |
{ | |
//print_r( $wp->query_vars ); | |
if ( array_key_exists('Badge', $wp->query_vars) && | |
array_key_exists('Password', $wp->query_vars ) && | |
array_key_exists('Username', $wp->query_vars ) ) { | |
$b = $wp->query_vars['Badge']; | |
$p = $wp->query_vars['Password']; | |
$u = $wp->query_vars['Username']; | |
do_something_important(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment