Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am running WP multi-site and BP. The plugin in question is Anti-Splog by WPMUDEV. They have advised they do not support customisations.

Anti-Splog tries to limit spam blogs from appearing on your multi-site network.

I am running a subdomain install. Therefore, on the form where the signup for a subdomain occurs, I want to autofill the value of the form box, and lock it so the user sees the subdomain.

However, even by forcing the $string as the value, it will not continue on to create the new subdomain blog. It says, please enter a value.

This is the random string 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?

The subdomain box needs to be the random subdomain string above on a new site registration.

Can any php guru could help please?

Thanks in advance,

Johnny

share|improve this question

2 Answers 2

Not sure where you are placing the code as you don't say - but you will need to edit the WordPress signup code / file and add your random string code in there and then hide the input for the sub-domain or set it to disabled and set it's value to the random string.

You'll then also need to encode the same random string in the form and check that the encoding is correct when the form is submitted so that you know it hasn't been changed (it would be easy to change the random code in the HTML using something like firebug).

Once you get past the processing then the blog creation will be the same and antisplog will work as before.

share|improve this answer
    
Thanks caffeinated, the code is in the ust-wp-signup.php which is the second code paste above. The two <input> tags. I will try firebug, as I was manually editing the php file, then creating a new blog. However I got the error above. I think it is an encoding issue. Will let you know. Thanks –  johnnymestizo Jan 6 '12 at 22:14
    
That was painful. All fixed now. :) –  johnnymestizo Jan 7 '12 at 18:08
    
Well, done - but you don't have any checks in there to ensure that your user doesn't use firebug to edit the string you set - which is very easy to do. –  caffeinatedb Jan 8 '12 at 18:22
<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 />';
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.