What I'm trying to accomplish here is having the viewer enter a password/key into a form on one WP page. If the password is correct, the page will redirect to a second page. I've found this question already:
Is it possible to direct users to a certain post based on a password entered on the home page?
but as near as I can tell this only works to redirect to a post and I need the viewer to be redirected to a page. Does anyone know how to best accomplish this? Is there an easy was of adapting tnorthcutt's code from here
if(isset($_POST['homepagepassword'])){
$post_password = $_POST['passwordfield'];
$post_id = $wpdb->get_var( $wpdb->prepare("SELECT ID FROM $wpdb->posts WHERE post_password = %d", $post_password) );
$q = new WP_Query( 'p=$post_id' );
if($q->have_posts()){
while($q->have_posts()){
$q->the_post();
wp_redirect(get_permalink());
die();
}
} else {
// oh dear, there isnt a post with this 'password', put a redirect to a fallback here
wp_redirect('http://www.google.com');
die();
}
wp_reset_query();
}
to redirect to a page instead of a post?