Title: Sends Draft Post Data to Facebook
Last modified: August 31, 2016

---

# Sends Draft Post Data to Facebook

 *  [Julie](https://wordpress.org/support/users/habannah/)
 * (@habannah)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sends-draft-post-data-to-facebook/)
 * Hi Viktor,
 * I think the plugin sends scrape info to Facebook even when the post status is
   Draft. I use the Redirection plugin, which shows me 404s coming from Facebook
   for post ids that are still in draft status. Is there any way you can make sure
   the status is published before sending the scrape info to Facebook?
 * Thanks!
 * [https://wordpress.org/plugins/facebook-open-graph-scraper/](https://wordpress.org/plugins/facebook-open-graph-scraper/)

Viewing 3 replies - 1 through 3 (of 3 total)

 *  Thread Starter [Julie](https://wordpress.org/support/users/habannah/)
 * (@habannah)
 * [10 years, 1 month ago](https://wordpress.org/support/topic/sends-draft-post-data-to-facebook/#post-7434265)
 * Hi again [@viktor](https://wordpress.org/support/users/viktor/) Fröberg,
 * I’ve figured out that this is happening because of the `save_post` action hook
   being used to trigger rescraping. It runs whenever a post/page/CPT is created
   or updated, including auto-save drafts and revisions.
 * Thanks to [this article](https://tommcfarlin.com/wordpress-save_post-called-twice/),
   I thought that something like the following could be helpful:
 *     ```
       function __construct(){
       	if( ! wp_is_post_revision( $post_id ) && ! wp_is_post_autosave( $post_id ) ) {
       		add_action( 'save_post', array($this, 'post_scraper'), 90, 2);
       	}
       }
       ```
   
 * However, there are still some issues with this solution:
    - I’m not sure if this works for taxonomy terms
    - Rescraping still occurs on other undesirable post statuses (future, pending,
      draft, private…)
 * Ideally, the scraper would only run when a piece of content is first published(
   and the published status is “public”), and then afterwards whenever it is saved
   by pressing the Update button (and not for every auto-save, for which I believe
   the default interval is 1 minute, though I may be wrong since I’ve customized
   my setup).
 * So then I thought perhaps something like this:
 *     ```
       function __construct(){
       	if( get_post_status ( $ID ) == 'publish' ) {
       		add_action( 'save_post', array($this, 'post_scraper'), 90, 2);
       	}
       }
       ```
   
 * But I still don’t know if this would work for taxonomy terms. Moreover, I don’t
   know how this would handle the status transition from draft to published.
 * I’m fairly new at PHP, so I’d really appreciate if you could help me figure this
   out! Thanks 🙂
 *  Plugin Author [Viktor Fröberg](https://wordpress.org/support/users/viktorfroberg/)
 * (@viktorfroberg)
 * [10 years ago](https://wordpress.org/support/topic/sends-draft-post-data-to-facebook/#post-7434266)
 * Hi!
    Sorry for the late answer! Great work! I’m note sure you’ll get the right
   post status outside of the save_post hook. So I think the best thing is to add
   a check at the beginning of the post_scraper function, since we have the $post
   object there, and it contains the post status 🙂
 *  I’ll try to implement this and release a fix this week, before my vacation 🙂
 * Btw, the plugin is open source and available on [github](https://github.com/Angrycreative/facebook-open-graph-scraper),
   pull requests are always welcome!
 * / Viktor
 *  Thread Starter [Julie](https://wordpress.org/support/users/habannah/)
 * (@habannah)
 * [10 years ago](https://wordpress.org/support/topic/sends-draft-post-data-to-facebook/#post-7434267)
 * Thanks for looking into this, Victor! I appreciate the help 🙂 I don’t know much
   php so I really had no clue what the next step should be, or even how to test
   my changes…
 * I can submit a pull request if you want me to, but I’ve never done that before,
   so perhaps you wouldn’t mind guiding me through the process?

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘Sends Draft Post Data to Facebook’ is closed to new replies.

 * ![](https://s.w.org/plugins/geopattern-icon/facebook-open-graph-scraper_fc9596.
   svg)
 * [Facebook Open Graph Scraper](https://wordpress.org/plugins/facebook-open-graph-scraper/)
 * [Support Threads](https://wordpress.org/support/plugin/facebook-open-graph-scraper/)
 * [Active Topics](https://wordpress.org/support/plugin/facebook-open-graph-scraper/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/facebook-open-graph-scraper/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/facebook-open-graph-scraper/reviews/)

 * 3 replies
 * 2 participants
 * Last reply from: [Julie](https://wordpress.org/support/users/habannah/)
 * Last activity: [10 years ago](https://wordpress.org/support/topic/sends-draft-post-data-to-facebook/#post-7434267)
 * Status: not resolved