admin管理员组文章数量:1426049
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.
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.
Share Improve this question asked Jun 10, 2019 at 22:21 graygray 11 bronze badge1 Answer
Reset to default 1It 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.
本文标签: plugin developmentPage is loading after submit before the file is processed
版权声明:本文标题:plugin development - Page is loading after submit before the file is processed 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745416595a2657713.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论