0

I have built a user import page that imports via csv file upload. The issue I am having is that the page is loading before all of the rows (user information) is finished processing/ inserting users. It works fine if there is 1 or 2 users/ rows in csv but beyond that it does not complete the job.

Is there a way to delay the page load until the process of importing the users from the csv file is completed?

The use case goes like this. A user goes to the import page, browses files (csv) then clicks submit. After clicking the submit, a function kicks off that processes each row in the csv and imports user into wordpress. The csv file could have hundreds of rows or just a handful. The page will keep loading until the process is complete. Once complete the page loads and has an output(log) of all of the users that were imported.

The part that I am stuck on is giving enough time for the process to finish before the page is loaded.

1

It sounds like you're running into the server's timeout setting (usually between 30 and 60 seconds). Once you hit that point, the page stops loading and returns as much as has been processed. In your case, I would try loading portions of the csv as pages just like paging through posts in WordPress. If you need to load the full csv, try loading it in dynamically with AJAX requests until the fill csv is loaded.

If you're doing any processing on the csv, I would do these in chunks as well to prevent hitting this timeout. You could do this with scheduled tasks, AJAX requests, or even via the command line, if that's a possibility.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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