TonyV
El Presidente
Just Getting Started
Member Likes (0)
I am able to add hyphens when I create a new blog from the admin, but I notice this can not be done when someone signs up, same is true with capital letters. Not so concerned about the capital letters, but is there a simple solution to allow new signups the option to use hyphens in their blog name?
thanks for any input.
Tony V
Responses (9)
Erstwhile founder (joined May 2007) Likes (0)
It can be done via the "wpmu_validate_user_signup" filter. However, it's just easier to hack wpmu-functions.php.
If you're using wpmu 2.7 look at lines 893-948.
Thanks,
Andrew
Member (joined February 2009) Likes (0)
Thanks Andrew,
looks like a basket of words to me. I have this;
if ( empty( $user_name ) )
$errors->add('user_name', __("Please enter a username"));
$maybe = array();
preg_match( "/[a-z0-9]+/", $user_name, $maybe );
if( $user_name != $maybe[0] ) {
$errors->add('user_name', __("Only lowercase letters and numbers allowed"));
}
$illegal_names = get_site_option( "illegal_names" );
if( is_array( $illegal_names ) == false ) {
$illegal_names = array( "www", "web", "root", "admin", "main", "invite", "administrator" );
add_site_option( "illegal_names", $illegal_names );
}
if( in_array( $user_name, $illegal_names ) == true ) {
$errors->add('user_name', __("That username is not allowed"));
}
if( is_email_address_unsafe( $user_email ) )
$errors->add('user_email', __("You cannot use that email address to signup. We are having problems with them blocking some of our email. Please use another email provider."));
if( strlen( $user_name ) < 4 ) {
$errors->add('user_name', __("Username must be at least 4 characters"));
}
if ( strpos( " " . $user_name, "_" ) != false )
$errors->add('user_name', __("Sorry, usernames may not contain the character '_'!"));
// all numeric?
$match = array();
preg_match( '/[0-9]*/', $user_name, $match );
if ( $match[0] == $user_name )
$errors->add('user_name', __("Sorry, usernames must have letters too!"));
if ( !is_email( $user_email ) )
$errors->add('user_email', __("Please enter a correct email address"));
if ( !validate_email( $user_email ) )
$errors->add('user_email', __("Please check your email address."));
$limited_email_domains = get_site_option( 'limited_email_domains' );
if ( is_array( $limited_email_domains ) && empty( $limited_email_domains ) == false ) {
$emaildomain = substr( $user_email, 1 + strpos( $user_email, '@' ) );
if( in_array( $emaildomain, $limited_email_domains ) == false ) {
$errors->add('user_email', __("Sorry, that email address is not allowed!"));
}
}
// Check if the username has been used already.
if ( username_exists($user_name) )
$errors->add('user_name', __("Sorry, that username already exists!"));
// Check if the email address has been used already.
if ( email_exists($user_email) )
$errors->add('user_email', __("Sorry, that email address is already used!"));
can you give me a hint which I should edit to allow for hyphen only, not under scores just -
thanks for any help.
Tony V
Erstwhile founder (joined May 2007) Likes (0)
Oops, I actually gave you the wrong lines. For the blog names the lines are 989-1040.
You would need to modify this bit(ln 1000):
preg_match( "/[a-z0-9]+/", $blogname, $maybe );
Unfortunately that's regular expression fun which I *really* don't care for. You'll need to do a google search to read up on it a bit.
Thanks,
Andrew
Member (joined February 2009) Likes (0)
I got it, it's actually line 1000 - 1002 thanks for getting me going.
Tony V
Member (joined February 2009) Likes (0)
in case someone finds this I should point out all I did was add the hyphen after the 9 so on line 1000 instead of;
preg_match( "/[a-z0-9]+/", $blogname, $maybe );
if( $blogname != $maybe[0] ) {
I got
preg_match( "/[a-z0-9-]+/", $blogname, $maybe );
if( $blogname != $maybe[0] ) {
works great :)
Tony V
Member (joined February 2009) Likes (0)
im thinking if you wanted to allow caps you probably could just add A-Z in there as well, but I am not in need of it, so I am not going to test it.
Tony V
Keeper of the Dark Chocolate (joined July 2007) Likes (0)
If I had been around, I would have pointed you to the trac ticket where all this had already been discussed. :)
http://trac.mu.wordpress.org/ticket/363
Well, way back when when it got discussed.
Member (joined July 2008) Likes (0)
RE: uppercase letters in blognames
http://trac.mu.wordpress.org/ticket/777
Blogs with uppercase letteres in blognames do not work properly.
Keeper of the Dark Chocolate (joined July 2007) Likes (0)
They do seem to have a small problem with that:
http://trac.mu.wordpress.org/ticket/898
WordPress Questions?
We've got answers!
Find out more »