Problem with change header location

You’re attempting to modify headers inside of a Composer, which you can’t do. By the time a Composer is being executed, the headers for whatever page you’re on have already been sent (in this case by wp-scripts, apparently). If you need to conditionally modify headers, you’ll need to hook into a action like wp_headers or send_headers, and do it outside of a Composer. Composers are meant for modifying data and passing it to views, not for containing redirect functionality, which appears to be what you’re trying to do here.

1 Like