I would like to allow my visitors to be able name their

I would like to allow my visitors to be able name their sites with hyphens. for example http://dev.btgmeetings.com/big-show-2016/

Right now they can only use letters like this http://dev.btgmeetings.com/bigshow2016/

Can this be changed?

  • Michael Bissett

    Hey @msqinc, Michael here! :slight_smile:

    That it can, we can hook into a filter provided by WordPress (as it's what's not allowing the hyphens to be used, rather than New Blog Templates), that being the wpmu_validate_blog_signup filter.

    The code provided here worked on my site:


    I inserted it into my site as a mu-plugin, like this:

    * Update to allow hyphens on blognames
    * @author Luis Franco
    * @param array $result
    * @return array $result
    function willow_allow_blognames_with_hyphens($result)
    $error_name = $result['errors']->get_error_message('blogname');
    if (!empty($error_name) && $error_name == __('Site names can only contain lowercase letters (a-z) and numbers.') || $error_name == __('Sorry, site names must have letters too!') && preg_match('/[^-a-z0-9]+/', $result['blogname'])) {
    unset ($result['errors']->errors['blogname']);
    return $result;
    return $result;
    add_filter('wpmu_validate_blog_signup', 'willow_allow_blognames_with_hyphens');

    To create an mu-plugin, go to your /wp-content/ folder via FTP, and find the folder called "mu-plugins". If there is no folder with that name, then you'll want to create one. Then, create a file inside that folder, and give the file any name you like (making sure the file as an extension of .php, e.g. example.php) and paste the code in there.

    You don't need to activate that plugin, as it will be always be automatically activated.

    Let me know if this helps please! :slight_smile:

    Kind Regards,

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.