Subdomain form for anti-splog signup - force random string

Hiya,

I am running Anti-Splog on a subdomain wpmu install.

I have edited ust-wp-signup.php

I am able to generate a random string with this code:

$subdomainhash = array_merge(range(0,9),range('a','z'));
shuffle($subdomainhash);
$newsubdomain = implode('',array_slice($subdomainhash,0,32));
echo $newsubdomain;

Now, to force users to use that string on the select subdomain form I have to edit the following code:

<label for="blogname">' . __('Site Domain:') . '</label>';

	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
		<p class="error"><?php echo $errmsg ?></p>
	<?php }

	if ( !is_subdomain_install() )

		echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. esc_attr($blogname) .'" maxlength="60" />';
	else
		echo '<input name="blogname" type="text" id="blogname" value="'.esc_attr($blogname).'" maxlength="60" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span>';

	if ( !is_user_logged_in() ) {
		if ( !is_subdomain_install() )

	$site = $current_site->domain . $current_site->path . __( 'sitename' );
		else
			$site = __( 'domain' ) . '.' . $site_domain . $current_site->path;

		echo '<p>(<strong>' . sprintf( __('Your address will be %s.'), $site ) . '</strong>) ' . __( 'Must be at least 4 characters, letters and numbers only. It cannot be changed, so choose carefully!' ) . '</p>';
	}

It doesn't seem to matter if I force $blogname or $site to be $newsubdomain.

It does not fill the value of the form, or replace the above strings. I can't get it working?

Ideally, I want to stop users from choosing their own subdomain and force them to use the random subdomain string above on a new site registration.
I believe Aaron developed this plugin. But any php guru could help.

Thanks in advance,

Johnny

  • johnnymestizo

    That was excruciating, but works beautifully !

    Please donate some rep points if you get to use this code in your site. I only need 200 points donated to get my lifetime membership!!! Thanks

    To get forced subdomains for new sites just modify the anti-splog file ust-wp-signup.php:

    <label for="blogname">' . __('Site Domain:') . '</label>';
    
    	if ( $errmsg = $errors->get_error_message('blogname') ) { ?>
    		<p class="error"><?php echo $errmsg ?></p>
    	<?php }
    
    $subdomainhash = array_merge(range(0,9),range('a','z'));
    shuffle($subdomainhash);
    $newsubdomain = implode('',array_slice($subdomainhash,0,32));
    
    	if ( !is_subdomain_install() )
    
    		echo '<span class="prefix_address">' . $current_site->domain . $current_site->path . '</span><input name="blogname" type="text" id="blogname" value="'. $newsubdomain .'" readonly="readonly" maxlength="60" /><br />';
    	else
    		echo '<input name="blogname" type="text" id="blogname" value="'.$newsubdomain.'" maxlength="60" readonly="readonly" /><span class="suffix_address">.' . ( $site_domain = preg_replace( '|^www\.|', '', $current_site->domain ) ) . '</span><br />';

    Cheers

    Johnny