I rarely deal with cookies and not sure about complete mechanics there, but here is basic working example of passing current user’s cookies to retrieve preview page source:
$preview_link = set_url_scheme( get_permalink( $post->ID ) );
$preview_link = esc_url( apply_filters( 'preview_post_link', add_query_arg( 'preview', 'true', $preview_link ) ) );
$cookies = array();
foreach ( $_COOKIE as $name => $value ) {
$cookies[] = new WP_Http_Cookie( array( 'name' => $name, 'value' => $value ) );
}
$request = wp_remote_get( $preview_link, array( 'cookies' => $cookies ) );
$body = wp_remote_retrieve_body( $request );
Related Posts:
- How to add an admin notice upon post save/update
- Post preview mechanism architecture
- Post/Page Preview Template
- How to mark articles as read?
- Listen to Post action
- Manipulate post category after time
- How to disable drafts?
- WooCommerce – Create Products Programatically [closed]
- which action to hook to in order to perform post-publish action
- Cannot access current post’s ID in custom plugin
- Set number of article per number of page
- How to change post status from publish to draft using hook in wordpress?
- prevent showing posts of an specific category in admin posts section
- Enable commenting on front-end preview page for pending posts
- Does WordPress remove draft status automatically?
- Using radio button meta data from a custom meta box
- Don’t post or draft if post already exists
- Post preview and oembed provider issue using polylang plugin with subdomains
- Two posts are loaded instead of one?
- What differences are there between a Privately Published post and a Draft post?
- How to store an extra (surrogate) ID when creating a post with wp_insert_post?
- Global $post not working in OOP function WordPress
- Bulk unpublish posts between specific dates (e.g. from April 2017 and earlier)?
- WordPress version 3.8 – Preview button not working for editor
- Define a wordpress constant through plugin functions?
- Dashboard :10 Last draft page and 10 last pending review page (metabox)
- Custom post preview without saving
- How to get post bulk edit action trigger and get edited post ids?
- Hiding Draft Post In Admin
- updating a post doesn’t trigger a function
- Hide a specific category in admin All Posts page (WordPress)
- Prevent Delete Attachment by URL or When Submit
- What hook do you use to update a post?
- Updating post data on save (save_post vs wp_insert_post_data)
- Lost draft under all posts and drafts
- Change target of view link in admin
- What happens if I delete all the rows that represents a post revision from the posts table into WordPress database?
- How to get the old WordPress Draft Editor view back with the Word count?
- Filter Hook for post table (not columns)
- why str_replace targeting pages instead just targeting post?
- l accidentally permanently deleted a Draft. There’s any way I can recover it?
- Get author posts count after excluding a category
- Stop post submission without losing data?
- Cant’ Grab WordPress Built-in Posts Through Loop
- How can my plugin display a populated new post window
- search content of pages and list in wp-admin
- Finding a post’s slug
- Insert specific information to a posts of a predefined category
- Hide content from Post Preview
- Open a wordpress single post in a lightbox without the header and footer
- Preview page/post revisions without overwriting current content
- Site/Post preview is not working on all social media
- Hook when post is set from published to draft?
- My posts are getting to Auto draft when I try to Publish
- WordPress: Develop multiple posts with different data
- How do I change the post title’s link on the posts page?
- How do I prevent draft posts from being accessible publicly?
- Connection dropped due to file size
- Update user meta when post published no working
- Fixing the WP Post Object for Custom Route
- Post preview in iframe without saving the post
- Export Posts with specific custom fields by sql
- Custom plugin to get related posts by category
- how to chang preview of list of articles of one category?
- WordPress is creating a lot of draft posts
- Preview own posts if logged in
- Latest news mini images
- Hide the contents for specific post
- Return All Post from publish to draft [duplicate]
- Display draft posts on single pages [duplicate]
- Error 404 blog/page/2/
- Onclick open posts displayed in slider in a popup [closed]
- How do I save JS classes being applied to the WP dashboard via custom plugin?
- WordPress + Polylang – Error 404 when trying to preview draft post on different language
- Filter only the text in the_content
- How to create new post content templates for my users?
- When open add new post or page WordPress add post with ID=0 continuously [closed]
- Start post pagination at 0 instead of 1
- display random posts on index.php instead of latest
- Thumbnail & Category link aside post
- Saving custom fields to a custom taxonomy
- Automatically Import WordPress Blog to Facebook Page [closed]
- Increase 10 post limit per page
- My wordpress based site is publishing the same post twice
- How do I change the core post search algorithm? Where is it found/constructed?
- Hooking into the post editing screen for an existing page only
- wp_query random post
- wp_posts table: safely remove unused columns to save database storage
- hiding permalink in admin if the user is subscriber
- Editing 375 posts simultaneously? Maybe from the database?
- Why does WP_Post not contain its permalink?
- Query Posts by Custom Field
- the_permalink() not working in a root installation
- Shortcode to display the latest news article within a page
- How to make the first post in the loop be styled like a “new / featured” post?
- Anyone know why wordpress converts some html entities to their numeric equivalents?
- What do comments with […] mean?
- Adding a blog archive with pagination using WP_Query
- How to Mysql select a list of posts with meta_values AND all relevant categories?
- How to get Tags with specific post id