How to prevent pro-sites to ask the user for the site subdir

How to prevent pro-sites to ask the user for the site subdir name 'your site' but to assign it a predefined value, via a hook action?

  • Panos

    Hi kk ,

    I bumped into this while I was doing some housecleaning. So sorry we missed this request and taking so long to get back to you about this.

    Although it probably is to late, easiest way would be to do that with some js, else it would require to modify plugin files. I'll share s simple script that would add that js and set as blog name the username + the number of blogs user has:

    add_action( 'signup_blogform', function(){
    
        $site_name = '';
        if ( is_user_logged_in() ) {
    
            $site_name = get_userdata( get_current_user_id() )->user_login . ( count( get_blogs_of_user( get_current_user_id() ) ) + 1 );
        }
    
        ?>
        <script type="text/javascript">
            (function($,d){
                $(d).ready(function(){
    
                    var blogname_field = $( '#blogname' ),
                        user_name_field = $( '#user_name' )
                        site_name = '<?php  echo $site_name; ?>';
    
                    if ( blogname_field.length ) {
                        blogname_field.hide().prop( 'type', 'hidden' ). val( site_name );
                        $('#prosites-signup-form-checkout > .blogname').hide();
                    }
    
                    if ( user_name_field.length ) {
                        user_name_field.on('change', function(){
                            blogname_field.val( $(this).val() );
                        });
                    }
                });
            })(jQuery, document);
        </script>
        <?php
    });

    Above snippet should be added in a custom plugin or in a mu-plugin. Here is some information about mu-plugins:
    https://premium.wpmudev.org/manuals/wpmu-manual-2/using-mu-plugins/

    Kind regards!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.