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.

We need to limit the blog names users may choose when they create their own blogs.

We have a WordPress Network configured to have all blogs share a domain name. E.g., domain.name.com/x, domain.name.com/y, etc.

We have integrated our WordPress Network with our corporate Active Directory using the Active Directory Integration plugin. That plugin puts the user's mailnickname attribute (the part of the email address before the @) into the nickname field.

I would like to allow users to self-create their own blogs but restrict blog names names so that it must match the nickname field of their WordPress account. E.g., a user with nickname jdoe could only create a blog named domain.name.com/jdoe.

Ideally, on /wp-signup.php, it would be best if the blogname field doesn't even display.

Is there a way to do this without PHP customization? I was hoping a plugin would already exist, but I can't find one.

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

Looking at the source of wp-signup.php, it looks like your best bet might be to filter signup_blog_init (line 303 in v. 3.5.1):

/*
add_filter( 'signup_blog_init', 'wpse103022_blog_name' );
function wpse103022_blog_name( $blog_details ) {
    // Set $username to the user's username
    $blog_details['blogname'] = $username;
    return $blog_details;
}
*/
// see code below for replacement

I'm not 100% sure this will work, but it's worth a try.

Edited

OK, after your comment below, I took a look at validate_blog_signup(). It calls wpmu_validate_blog_signup(), and that provides a filter -- wpmu_validate_blog_signup. Looking at the code, it appears that something like the following should work:

add_filter( 'wpmu_validate_blog_signup', 'wpse103039_blog_name' );
function wpse103039_blog_name( $blog_details ) {
    $blog_details['path'] = '/' . $desired_blogname; // however you get it
    return $blog_details;
}

If I'm reading the code right, you can filter:

  • domain
  • path
  • blogname
  • blog_title
  • user
  • errors
share|improve this answer
    
Thank you! Our usernames are random 8 digit numbers, so I need to use the user's nickname attribute. –  Aren Cambre Jun 15 '13 at 13:04
    
OK, I'm finally in to this deeply now. It looks like signup_blog_init is just for making the signup form, not for processing the signup after the user presses submit. It looks like validate_blog_signup is what I'm after here, and it appears to have no hooks. :-( Specifically, looks like I need to replace instances of $_POST['blogname'] with the value that I need to use instead. –  Aren Cambre Jul 16 '13 at 16:45
    
Updated answer with new info -- hopefully this'll do what you need. –  Pat J Jul 16 '13 at 18:51
    
I appreciate the discovery. I didn't think to look in ms-functions.php. Still has no effect. Looking further. –  Aren Cambre Jul 17 '13 at 13:52
    
OK, this is it: $blog_details['path'] = "/".$desired_blogname;. Update your answer and I'll mark as accepted. –  Aren Cambre Jul 17 '13 at 14:52
show 6 more comments

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.