0

I am on EE 2.11.2, and I am using the Channel Entries API to create a new channel entry after a user submits a form on the front-end. It saves the entry just fine, but when I redirect the user to the view template for that new entry, most of the time, the page is blank.

If I refresh the page, it displays the entry. Also, if I sleep() in PHP for a bit before redirecting, it seems to show the entry rather than the blank page more often.

Is there a way to get around this? Am I doing something wrong?

2 Answers 2

0

Did you try to set error reporting in EE preferences to show errors to everyone? Perhaps there is an error and you just don't see it.

If the blank page means no results, the most obvious is checking entry status. By default the enties published via channel form are set to Closed status (unless you specify other status explicitely and the user has access to that status).

1
  • There are no errors showing. The status is correctly set. Remember, that it works fine if i add a sleep(3) before redirecting, OR if I just refresh the page that I was directed to. It's like there is a delay in actually saving the entry sometimes. Or it gets redirected before the entry is fully saved... Sep 29, 2016 at 15:32
0

Ifigured it out!

When creating the entry with the Channel Entries API, I was setting the entry_date value to be ee()->localize->now. After it saved, and got redirected within the same second, the view page was not returning the result because the channel entries query was checking for entries with an entry_date < the current timestamp. So It wasn't finding this entry saved in the same second as the query!

I fixed this by setting my entry_date to be ee()->localize->now - 1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.