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>
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.