Wordpress user is not assigned as author when the import is made with the cron job
Description
Wordpress user is not assigned as author when the import is made with the cron job. When the import is made with the Run now button, it works fine.
Import with run now - https://vertis.d.pr/i/GvxeaR Import with cron job - https://vertis.d.pr/i/oTPV0P
Reported here - https://wordpress.org/support/topic/cron-imports-the-posts-without-the-author/
Step-by-step reproduction instructions
- Create an import
- Run it with the run now button
- Purge & reset the import
- Install WP Crontrol plugin and run the feedzy cron job
Screenshots, screen recording, code snippet or Help Scout ticket
Import with run now - https://vertis.d.pr/i/GvxeaR Import with cron job - https://vertis.d.pr/i/oTPV0P
Reported here - https://wordpress.org/support/topic/cron-imports-the-posts-without-the-author/
Environment info
WordPress 6.4.3 / Feedzy 4.4.2
Is the issue you are reporting a regression
Yes, this is a regression.
After the investigation, this is not a bug. When the cron runs and no user is logged in, it marks that post_author as 0
The code that fetches the author is here: https://github.com/Codeinwp/feedzy-rss-feeds/blob/0c044f6ee263b6226ae932bb3e0e6f18e9884964/includes/admin/feedzy-rss-feeds-import.php#L2731-L2736
The behavior of fetching the user: https://developer.wordpress.org/reference/functions/wp_get_current_user/
@vytisbulkevicius, should we set the default author as admin?
@irinelenache,
I thought as well that even with cron run in the past we were assigning the user who originally created the import job as the author but I can't find the proof of it in old tickets or related GitHub issues so it probably always worked like this.
We have a clean solution of passing any existing user as author when configuring import Job, it's here - https://docs.themeisle.com/article/942-in-feedzy-how-do-i#pass-author-ID
I think it fully covers this issue and is even more flexible.
I'm putting this in a backlog now, we can see if it's important to use the creator of the import job as the author based on more requests.