Moodle | This page should automatically redirect

|
| By Webner

In my plugin code I was trying to redirect from one page to another page using redirect as follows:

redirect("success.php?cd=".$id);

Redirecting to the other page was working but during redirection an intermediate page was being displayed like this:
31

On click of continue button, it was redirecting to my second page i.e. success.php.

Solution: Reason for appearing Continue screen during redirection was that something was being printed in the code with ‘echo’ or ‘print’ statement before redirect was called.

After Removing ‘echo’ or ‘Print’ statement redirect started to work without the intermediate page.

If no ‘echo’ or ‘print’ statement is found in your code enable Debugging in Moodle (set to ‘Developer’ and display). You may see a warning message that might explain why the redirect is not working immediately. Also make sure there are no unwanted inline HTML sections like spaces (or any other characters) before the opening ‘<?php’ tags in your file.

 

Leave a Reply

Your email address will not be published. Required fields are marked *