User login not redirecting back to course

Hello,
I have finished implementing my template on coursepress, everything is fine except one detail on login and purchase.

By default I'm redirecting users not logged to a [cp_pages page="student_signup"] and [cp_pages page="student_login"] page in which the user can both login or signup. I do this by verifying if he is logged in and passing the parameter ?course_id=XX in the end of the URL.

If it's a new user and he signs up. He will go back to the course page where he can finish the purschase process through WooCommerce.

If he is already registered, he goes straight to the panel screen. I need a way to override this setting and send him back to the course page, so I avoid losing sales.

How can I have this issue fixed?
Thanks a lot.