Support » Networking WordPress » How to disable Multisite sign-up page?

  • If we try to access a non-existant Multisite site, e.g., http://site1.example.com or http://example.com/site1/, we are redirected to http://example.com/wp-signup.php?new=site1.

    How to block this and redirect the browser to another page?

    I created a mu-plugin but it is not redirecting to the homepage. I just get a blank page;

    <?php
    add_action( 'signup_header', 'rbz_prevent_multisite_signup' );
    
    function rbz_prevent_multisite_signup() 
    {
    wp_redirect( site_url() );
        die();
    }
    ?>
Viewing 5 replies - 1 through 5 (of 5 total)
  • Moderator bcworkz

    (@bcworkz)

    Try using the ‘ms_network_not_found’ action instead.

    Thread Starter birblogcu

    (@birblogcu)

    @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.

    Moderator bcworkz

    (@bcworkz)

    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 );

    Thread Starter birblogcu

    (@birblogcu)

    @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.

    Moderator bcworkz

    (@bcworkz)

    Sorry, I’m at a loss for any more thoughts. I don’t have the ability to investigate a wildcard setup.

Viewing 5 replies - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.