Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
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
add comment

2 Answers

up vote 1 down vote accepted

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

share|improve this answer
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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