I am using
wp_cron to auto grab posts from a remote website and save them in my wp db.
NOTICE! I am executing my code from my plugin, not from my template functions.php or somewhere else. I have my own validation of grabbed content to prevent malicious code etc. so turning off security validation in wordpress is not an issue in my case, but be careful if you don't have your own validation of grabbed content. Always validate grabbed values if possible!
I have in my plugin one button to grab posts manually by clicking on this button and it works perfect. Everything is stored as I want in my database. No problem here.
but then I have a
wp_cron function that runs for testing purposes every two minutes (if somebody clicks on my page, of course ;) and here is a problem.
Notice that the code is identical, just instead of
get_user_id() I set it manualy to
1. that's probably the only change between these two codes.
And the problem is that everything is stored as expected including time, title, slug, (it even grabs and downnload and set the featured image for the post correctly), tags, categories and additional taxonomy too. So that fine.
Only thing that is missing is the body text (content) of the post.
When downloaded from admin manually. It's something like:
<iframe width="650" scrolling="no" height="450" frameborder="0" src="http://example.com/embedframe/3843634"></iframe>
<object height="450" width="650" ><param name="movie" ... bla bla bla ... shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" height="450" width="650" /></object>
So, it is because it is filtered and striped out, I mean
iframe when not logged in as an admin?
If so, how can I turn it off in my plugin?
Or is it something else?
I really think it's only something with WP security issue, because the code works when performed from admin as admin manually. And the code of the function is the same and all variables are passed in as expected. Just content is not saved.
It's definitely something with the WP security. When I set in my auto cron function content variable manually to "Testing auto save." is is saved normally. But When I set it to
<object>blablabal</object> it is NOT.
How to turn this "checking" off, so I can save my code with cron?