I am having a huge argument with Wordpress, and this is my last port of call before I throw the PC out of the window.

I have a plugin here that exports an XML feed into Wordpress posts. The posts have an image which is saved locally, the HTML to display the image is then inserted at the beginning of the post content, before being inserted into Wordpress using wp_insert_post.

I'm having a slight issue though. The script works fine when it is turned on manually. But as soon as it triggered by cron, the post will import fine, but the image will not save locally, and the HTML for the image is not present in the posts content.

I really am at a loose end. I thought it was to do with permissions, and the fact that the posts were being imported with no author. I then changed it so they were marked as written by an admin, but that made no difference.

What is the problem of running it via cron vs running it manually when logged in?

What does the function that runs on wp_insert_post look like?
–
tollmanzJul 12 '11 at 14:51

WP Cron problems are hard to debug, so take a deep breath first. Maybe the image import is done via AJAX which does not work in cron? Are you using a specific plugin? If so, please reference.
–
hakreJul 12 '11 at 14:56

The images are simply downloaded to the server using PHP fopen.
–
DannyJul 12 '11 at 15:37

Furthermore, it's not a specific plugin, just one that was developed inhouse by us. But we are stumped. It's also stopped functioning on the latest Wordpress (3.2), but it works on 2.8.6, but that's a whole other story.
–
DannyJul 12 '11 at 15:38

I think the main issue here is it works completely when it is activated, so it must be something that's not accessible from cron, but it's identifying what.
–
DannyJul 12 '11 at 15:39