You can use the init
hook to check the $_REQUEST
or $_GET
super-global variable for your token
value and then redirect to pages that are present via WP Core:
home_url
wp_login_url
If you pass additional parameters to these URLs, such as token_valid=true
you can use that along with conditional tags like is_front
to conditionally display thank you message.
function wpse290114_init_validate() {
if(isset($_REQUEST['token']) && !empty($_REQUEST['token'])){
// validate the token and set $token_valid to 'true' or 'false'
if($token_valid){
wp_safe_redirect(add_query_arg( 'token_valid', $token_valid, home_url() ));
} else{
wp_safe_redirect(add_query_arg('token_valid', $token_valid, wp_login_url() );
}
}
}
add_action("init", "wpse290114_init_validate");
The position and display of the thank you message depends on the theme.
function wpse290114_thankyou(){
if(isset($_REQUEST['token_valid']) && 'true' === $_REQUEST['token_valid'])){
echo '<p class="message--thankyou">Thank you for validating.</p>';
}
}
add_action("your_theme_hook", "wpse290114_thankyou");