Viewing 2 replies - 1 through 2 (of 2 total)
  • I also struggled with this one for quite a while but I have just realised the likely solution – which is not a bug in the plugin code but rather with WP user capabilities…

    1. Firstly, make sure you’re running the latest version because the Post Format import did have an issue before the release in Sept ’14 (see the GitHub thread at https://github.com/ozh/ozh-tweet-archiver/issues/5 for more info).

    2. If you’re still having an issue then there’s a strong chance it’s related to the user you’re using during auto-import. I couldn’t understand why Post Format was being assigned correctly when I did a manual import but not when I did an auto import. The WordPress documentation at https://codex.www.ads-software.com/Function_Reference/wp_insert_post#Parameters states

    ‘tax_input’: Equivalent to calling wp_set_post_terms() for each custom taxonomy in the array. If the current user doesn’t have the capability to work a taxonomy, the you must use wp_set_object_terms() instead.

    Tweet Archiver uses the tax_input method above and therefore effectively uses wp_set_post_terms(), so if the user you have set to use for all the Auto Import posts doesn’t have the correct capabilities there’s a strong chance that the Post insertion will work but not the Post Format – the outcome being what you’re seeing. I’m assuming that when doing a manual import the capabilities are taken from the currently logged in user rather than the user you have set in Tweet Archiver settings.

    Note: All the above is theory at the moment but I’m eagerly awaiting my next ‘auto import’ (now using a user with Admin privileges) and then I’ll know for sure if my theory is correct. ??

    Turns out my above logic was wrong. I was still in the position where importing worked manually but not for auto-imports. Whether this is related to WP Cron, permissions, etc. I have no idea but I can’t crack it and can’t spend any longer on it.

    Instead therefore I’ve now amended the plugin code (not a very clever idea) to update the Post Format after the post is created rather than when it is created. It probably incurs a extra DB hit and the change would have to be re-applied if the plugin were updated but in case it helps anyone else, here’s what I added to line 303 of import.php:

    // Post format - updating post with format after initial post creation
    // because method above on line 293 fails for auto-import in some circumstances
    if ( 'standard' != $ozh_ta['post_format'] ) {
      set_post_format($post_id, $ozh_ta['post_format']);
    }
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Twitter Archiver not applying Format’ is closed to new replies.