Wp redirection doesn’t not change url in browser

In which case wp_redirect can change content of the page without change the url ?

No, if used correctly there are no situations where wp_redirect interferes with the content of a page. It’s job is to do a HTTP redirect telling the browser to stop and start a new fresh request using a new URL, and that is its only job. Your HTAccess is not a factor in this. If the URL did not change then there was no redirect.

I suspect that you’ve either called the function in the middle of a page when it is too late to redirect, and that you also did not exit; after calling it like the documented examples show, and it’s very likely that your PHP error log is full of warnings and errors about “headers have already been sent”.

How To Redirect

To use wp_redirect, it must be called before any output is sent. The moment something is sent to the browser, be that whitespace or the opening HTML tag, all opportunities to use wp_redirect have ended. This means you can never use it in a shortcode widget or block.

If you want to use it, it must be done on a hook, and one that runs before the template is loaded. It must also have an exit statement immediately after it.

Note that when I say HTML, I mean any HTML, not just post HTML, but headers, meta tags, <head> or even blank spaces. From the moment of the first echo or ?> PHP will send out HTTP headers telling the browser to expect HTML and your chance to redirect has gone and cannot be recovered. The only way to redirect at that point is to do it in javascript or HTML.

Which Hook?

Which hook you should use depends on how the plugin you’re working with is built. There are a number of generic hooks that might work such as init/after_theme_setup but this cannot be done from a theme template or once HTML has been sent to the browser.

Your question states that you’re trying to use watupro_completed_exam, you would need to ask their support or read the plugins code to identify when this hook fires to see if it can be used for this.

This means what you want may not be fixable without the help of WatuPro because only they can change when the watupro_completed_exam hook fires, which may not be possible to do, and there is no generic WordPress fix for this specific use case.

tech