wordpress protected pages

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

Read More

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');

Related posts

Leave a Reply

1 comment

  1. Try this at the top of the page template, before the loop:

    if( get_query_var( 'token' ) == 'xyz' )
        query_posts( 'post_status' => array( 'publish', 'any' ) );
    

    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’:

    add_filter( 'query_vars', function( $query_vars ) {
        $query_vars[] = 'token';
        return $query_vars;
    });