Issues adding custom code to redirect to a thank you page

I’m trying to add the code provided on this thread to redirect the users who register a site using Pro Sites to a Thank You page that I’ve allready created and added to my theme folder, but I’m getting this error:

Warning: Cannot modify header information - headers already sent by (output started at /home/++++++/public_html/wp-content/themes/astra/header.php:13) in /home/++++++/public_html/wp-includes/pluggable.php on line 1216

I’ve tried adding the code using both alternatives (one at a time), by adding it to wp-config.php and by adding it to a mu-plugin, and in both cases I’m getting the same error any time a new user tries to register a site.