1

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 = 
wp_remote_retrieve_body(
wp_remote_get(
'http://localhost/mysite/test-post/?preview=true&preview_id=28&preview_nonce=640bc54ca4')); 
$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 '10 at 16:11
  • 1
    Have you tried passing the cookie information? – Jan Fabry Nov 29 '10 at 16:13
1

Have you checked out the following plugin?
http://wordpress.org/extend/plugins/public-post-preview/

0

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, privacy policy and cookie policy

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