I've got a plugin that needs to interogate the post preview (the contents of the rendered page that's presented when the user clicks "Preview Post".

To attempt to obtain this input stream into a code variable, I'm using wp_remote_get like so:

$response = 
$post->post_content = $response;

(I'm just replacing the post content with the results of the get for easy previewing during code testing).

My problem is that since I'm not passing any authentication parameters in the wp_remote_get, the preview action fails.

Is it possible to pass a parameter that authenticates the current user and returns the preview to the script?

  • 1
    What info from the page plugin actually needs? I just wonder if it is possible to get rid of going through HTTP.
    – Rarst
    Nov 28, 2010 at 16:11
  • 1
    Have you tried passing the cookie information?
    – Jan Fabry
    Nov 29, 2010 at 16:13

2 Answers 2


Have you checked out the following plugin?


Like Jan Fabry wrote, you need to pass the cookie information with the request. Basically that's the admins' login-cookie.

You can add those with the $args array parameter.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.