Working on a WordPress site that is pulling post data from a third party system via an externally triggered Cron. Everything seems to be working absolutely fine, except that as posts are being created each post slug has -2 appended as if there were already a post with the same name - except there isn't. This doesn't always happen, however. If I zero the post tables in the db and run the custom post import plugin, everything is fine to begin with.
I had a feeling it might be something to do with being logged into the back end when the Cron task runs, but I can't prove this and am not sure where else to look for the issue or the solution.
Tried adding "if ( ! current_user_can( 'edit_posts' ) )" before the import function runs, but this didn't seem to cure it. Not sure how to proceed so any help appreciated.
P.S. I'm not really a WordPress developer, more a designer who dabbles :)