总的来说,这是一个大问题
我们有一个
add_filter("wpmu_validate_blog_signup", "my_validate");
从这里开始,你必须绕过这个错误。由于一些版权问题,我无法向您展示我的确切代码,但至少是其中的一部分。在本例中,我们在允许的字符中添加连字符。我还通过google和stack overflow解决了这个问题
function my_validate($result)
{
$errors = $result[\'errors\'];
// we only want to filter if there is an error
if (!is_object($errors))
{
return $result;
}
// create a new var to hold errors
$newerrors = new WP_Error();
// loop through the errors and look for the one we are concerned with
foreach($errors->errors as $key => $value)
{
// if the error is with the blog name, check to see which one
if ($key == \'blogname\')
{
foreach($value as $subkey => $subvalue)
{
switch ($subvalue)
{
case \'Site names can only contain lowercase letters (a-z) and numbers.\':
$allowedchars = \'-\';
// so whatever you do, you can add something to the allowedchars and bypass the preg match.
// by the way , the exact error case you need to get from the language file
$allowed = \'/[a-z0-9\' . $allowedchars . \']+/\';
preg_match($allowed, $result[\'blogname\'], $maybe);
if ($result[\'blogname\'] != $maybe[0])
{
// still fails, so add an error to the object
$newerrors->add(\'blogname\', __("Only lowercase letters and numbers allowed"));
}
continue;