Links to my online courses are posted on various websites. The link look like this : https://example.com/course/view.php?id=31
When new users click on the link, they are brought to my Moodle website login page.
When they sign-up on my Moodle site with Google authentication, they are taken to the form where they need to fill up a couple of custom fields.
After they fill in the custom fields and submit, they are taken to preferences.php
Instead of the preferences.php, I need them to go to the original URL, which is stored in "wantsurl"
Right now, I have just edited the preferences.php and used a simple redirect to send users to the dashboard page.
What code can I add to the preferences.php page to redirect users to the original URL that they want to go to? i.e. "wantsurl"
Note: If I remove the custom fields, users are redirected to the course page (wantsurl) after authentication. But the custom fields are essential.