Register Site vs Register Username

I am using WordPress MultiSite and the Pro Sites plugin. Is there any way to have users click a link to register ONLY a username without having an option to gimme a site, and vice versa.

Or, have the radio button default to username instead of gimme a site.

  • Patrick

    Hi there @bruceleeon

    Welcome to WPMU DEV, glad to have you aboard!

    If I'm not mistaken, I believe you want to restrict site creation to logged-in users only. In other words, users must first create an account & login before they can create a site, is that correct?

    If so, then all you need to do is go to Settings > Network Settings and set Allow new registrations to Logged in users may register new sites.

    That will automatically update your register page so users can only create an account, not a site.

    I hope this helps! And thanks for being a member :slight_smile:

  • Patrick

    Hi again @bruceleeon

    I hope you're well today!

    Whoops, I apologize. What I recommended above will work only if our Membership2 plugin is being used. The M2 plugin actually replaces the default WordPress regisrtation process with its own, so this type of setup is possible.

    However, @Sajid is having a play with some ideas to see if some jQuery magic can be used to get this done for you. He'll reply here too when he has something to report. :slight_smile:

  • Sajid

    Hi @bruceleeon

    Hope you are doing good today :slight_smile:

    By default WordPress handles both registrations (user and sites) on same page in multisite.

    Using below code you can make wp-signup.php file allow only register a user at first and then allow only logged in users to register their website.

    function wpmu_hide_radio_buttons_on_signup_form(){
    
    	if( !is_user_logged_in() and isset($_GET['register']) and $_GET['register'] == 'site' ){
    
    			?>
    	<script type="text/javascript">
    		jQuery(document).ready(function($) {
    
    					$('.mu_register').html('You must login to register a site! <br><a href="<?php echo wp_login_url( wp_registration_url() ); ?>">Click here</a> if you are not automatically redirected to login page in two seconds. ');					
    
    					setTimeout (function(){
    							window.location.replace("<?php echo wp_login_url( wp_registration_url() ); ?>");
    					},2000);
    
    		});
            </script>
    	?>
    
    	<?php
    	}	else{?>
    
            <script type="text/javascript">
    		jQuery(document).ready(function($) {
    					$('#signupuser').attr('checked', 'checked');
    					$('#signupblog').parent('p').css({
    													 	'visibility': 'hidden',
    														'position' : 'absolute'
    
    													 });
    					$('.submit').val('Submit');
    
    		});
            </script>
    
    	<?php 
    
    	}
    }
    add_action('signup_extra_fields', 'wpmu_hide_radio_buttons_on_signup_form');

    How to use this function:

    1. Add above code in functions.php file of your child theme or use mu-plugin (add <?php tag before the code and a line break).
    2. Now use http://yoursite.com/wp-signup.php for user registration.
    3. Use http://yoursite.com/wp-signup.php?register=site (if visitor is not logged in it will be redirected to login page with delay of two seconds and showing a message).
    4. Feel free to edit message (strings) and delay (2000, 1000 = 1 second) according to your requirements.

    Hope it helps :slight_smile: Feel free to post a reply if you need further support later.

    Cheers, Sajid

  • bruceleeon

    Thank you very much!
    I modified the code a bit to include some instructions... what do you think?

    <?php
    
    function wpmu_hide_radio_buttons_on_signup_form(){
    
    	if( !is_user_logged_in() and isset($_GET['register']) and $_GET['register'] == 'site' ){
    
    			?>
    	<script type="text/javascript">
    		jQuery(document).ready(function($) {
    
    					$('.mu_register').html('<br /><h1>Welcome!</h1><br />You must login to register a site! <br /><br /><h2>Step 1:</h2> Register as a user: <a href="<?php echo site_url('/wp-login.php?action=register');?>">Click to Register</a><br /><br /><h2>Step 2:</h2>Register a Site: <a href="<?php echo site_url('wp-signup.php?register=site');?>">Click to Register Site</a><br /><br />');
    		});
            </script>
    	?>
    
    	<?php
    	}	else{?>
    
            <script type="text/javascript">
    		jQuery(document).ready(function($) {
    					$('#signupuser').attr('checked', 'checked');
    					$('#signupblog').parent('p').css({
    													 	'visibility': 'hidden',
    														'position' : 'absolute'
    
    													 });
    					$('.submit').val('Submit');
    
    		});
            </script>
    
    	<?php 
    
    	}
    }
    add_action('signup_extra_fields', 'wpmu_hide_radio_buttons_on_signup_form');

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.