I would like to access WordPress protected pages through of a token. The scenario would be: I pass a token in URL, than check if the requested is a page or not,if yes is the page protected or not, if yes check the URL has the token, if it has check if the token match or not.
UPDATE
The workaround what I found and is working in my case
function check_token() {
if (post_password_required() && (!empty($_GET['token'])) ){
if($_GET['token'] == 'test'){
global $post;
$post->post_password=null;
}
}
}
add_action('wp_head','check_token');
Try this at the top of the page template, before the loop:
I can’t find a post a status corresponding to “protected” – protected how? Find the actual post status in the list and replace “any” with it: http://codex.wordpress.org/Class_Reference/WP_Query#Status_Parameters
Here is how to register ‘token’: