Try using the ‘ms_network_not_found’ action instead.
@bcworkz Hi, thank you for your answer but I am getting the same result. It’s a blank page and the page doesn’t redirect to any URL.
A completely blank white page indicates there’s a PHP error somewhere, it could be a simple syntax error. Check you error log after making a non-existant sub-site request for any resulting errors.
Which kind of network do you actually have? Sub-domain or sub-folder? With sub-folder, requesting example.com/site1/ should result in a nothing found error on the root site because it’s seen as a single post request. On a sub-domain site, unless your server is configured for wildcard sub-domains, requesting a non-existant sub-domain like site1.example.com would typically result in a browser’s site not found error since “site1” is not a registered sub-domain in your DNS. Allowance for wildcard sub-domains is a rather niche application.
The point being I’m unclear how you’re getting to a signup page to start with. It could be some other plugin is also hooked into ‘ms_network_not_found’ and redirecting before your code has a chance to execute. Perhaps try hooking with this variant:
add_action( 'ms_network_not_found', 'rbz_prevent_multisite_signup', 0 );
@bcworkz
Thanks for your response.
I am creating the site network with subdomains and there is a wildcard DNS record. I tried the piece of code in your message and still it wasn’t redirected to the home page when the user typed in a non-subdomain.
Sorry, I’m at a loss for any more thoughts. I don’t have the ability to investigate a wildcard setup.