I have an EE template containing a process. The process is run once daily by loading the template in IE using Windows Task Scheduler at a given time each morning.
The process consists of two parts.
Part A uses the Query Module to collect specific channel data and emails them using the “Email-From-Template” plug-in. This part works fine, so ignore it for now.
Part B logs that the email was sent by creating a channel entry in a channel that was created to be an event log.
I am using the Channel Entry API’s
ee()->api_channel_entries->save_entry($data, $channel_id);to write the entry to the event log channel.
All has worked well in testing when I have loaded the aforementioned template manually. However, when I load the template automatically with IE/Task Scheduler, Part B fails with an error on the front end indicating, “You do not have permission to post to this channel,” or something to that effect.
It works when I’m doing it manually because I’m logged in as a registered site member. When Task Scheduler attempts to open the template in IE, it is doing so as a guest.
So here are my questions:
Is there a way to allow a template being loaded by a “guest” (IE/Task Scheduler) to add entries to a channel using the Channel Entry API?
If not, Is there a way to make IE/Task Scheduler load a template as a logged-in user?
I’m also open to any other suggestions anyone might have.
To clarify, I am not using the API to write an add-on. I am using it in PHP directly in a template.
Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.