502 Error showing when run the loop

Home Forums Legacy Support Support queries How-to & Troubleshooting 502 Error showing when run the loop

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #225319
    Aminul
    Participant
    Hi, I have faced a problem. I am trying to assign course using <span style="background-color: #212121; color: #82aaff; font-family: Consolas, 'Courier New', monospace; font-size: 14px; white-space: pre;">bp_course_add_user_to_course() </span> function. It working well but when I run the 4000 courses in the loop then it's showing 502 error. If I reduce the loop items like 100 then it's working fine. I need to assign the 4000 courses at a loop. How can I overcome this issue?   $the_query = new WP_Query( $args );             if ( $the_query->have_posts() ) {                 while ( $the_query->have_posts() ) {                     $the_query->the_post();                     bp_course_add_user_to_course($user_id,get_the_ID(),$time);                 }             }             wp_reset_postdata(); </div>
    #225349
    logan
    Member
    Hello, Yes, it won't work because your server is not strong enough to serve these huge amounts of request. Please try to run in the batches like 100 to 200. it should work.
Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘502 Error showing when run the loop’ is closed to new replies.