Disable the functionnality that reserve blog address when username is taken

Hi,

I’m wondering how can I disable the functionnality that reserve a blog address when username is taken?

This may make some sense in community like wordpress.com but at some point if you really want to reserve a blog address, you need to create the blog.

I need some help to figure out a way to do it without modifying the core because of updates (obviously).

Thanks

  • Tyler Postle
    • CGO

    Hi there Mattlegrand,

    Welcome to the WPMU DEV Community!

    Do you mean on the /wp-signup.php registration page?

    If you go to your Network Admin > Settings.

    Then you will see registration options. If you don't want to allow site registration at initial sign up then you can select "Logged in users may register new sites" or "User accounts may be registered" with the latter, users will not be able to create sites at all.

    Hope this helps! If you have further questions just let us know.

    Cheers,

    Tyler

  • mattlegrand
    • Flash Drive

    No, that’s not what I am talking about.

    There’s a feature in wordpress that will reserve a blog address (ex: bobby.blogplatform.com) to the “bobby” user. You just can’t register that blog address.

    It may sound like the correct behavior on platform like wordpress.com but it’s not always the case. In my case, bobby may have registered his username to post a comment with absolutely no intention to ever create a blog. And five years later, a legitimate bobby get declined a perfectly fine blog address for no good reason.

    I want to stop this “reservation” process without altering the core files.

    Have an idea?

  • Tyler Postle
    • CGO

    Hey Mattlegrand,

    Sorry I definitely misunderstood that in my last post, thanks for the explanation :slight_smile:

    I’m not sure how we would be able to do this without altering core files. I’m going to flag one of our SLS staff(coding experts) on this and they can have a look. I still can’t guarantee if it will be possible without altering core files, but we should at least find out for sure whether it is or not.

    Keep in mind SLS deal with more advanced threads so can sometimes take a little longer to reply.

    If you have any further questions in the meantime just let us know!

    Cheers,

    Tyler

  • Hoang Ngo
    • Code Slayer

    Hi @mattlegrand,

    I hope you are well today.

    This is a native flow of WordPress blog registration. When an user register a blog, WordPress will store the information inside the table _signups, and send an activation email to the user. When the user activates the site, now some more data will be added inside the table _sites & _sitemeta.

    The signup site will be stored in 2 days FYI.

    And because we can’t disable this, as this a part of WordPress. So I think we will have 2 solutions:

    1. We will run and clear the reservation in shorter interval, example some couples of hours instead of 2 days.

    2. We will prevent the email sending for activation, and create a site immediately when user signup. But this way can cause conflict with other plugins, & spamming issue. I prefer the #1 more.

    Please let me know which suite you, and I will create some custom code for you :slight_smile:

    Best regards,

    Hoang

  • mattlegrand
    • Flash Drive

    Hi Hoang,

    I understand the feature you are talking about and it’s not much of problem because it clears after 2 days. I can live with it.

    This is not the problem I have. You can register an username without creating a blog. Just a username for whatever reason. They don’t clear after 2 days, they don’t clear ever, unless I delete them. This will also reserve the blog address even if the user doesn’t plan on ever creating a blog.

    This is a problem because I have some prime URL being reserved to an user that posted a comments three years ago.

    I hope you understand as english is not my mother tongue.

  • Ash
    • WordPress Hacker

    Hi there

    Would you please try the following code?

    add_filter( 'wpmu_validate_blog_signup', 'wpmu_validate_blog_signup_cb' );
    function wpmu_validate_blog_signup_cb( $result ) {
    if ( username_exists( $result['blogname'] ) ) {
    if ( ! is_object( $result['user'] ) || ( is_object($result['user']) && ( $result['user']->user_login != $blogname ) ) ) {
    $errors = $result['errors'];
    $errors->remove( 'blogname' );
    $result['errors'] = $errors;
    }
    }
    return $result;
    }

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name ‘mu-plugins’. If there is no folder in that name, then create a folder, name it ‘mu-plugins’, create a file inside that, give any name you like and paste the code in there. You don’t need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.

    Hope it helps :slight_smile: Please feel free to ask more question if you have any.

    Cheers

    Ash

  • Ash
    • WordPress Hacker

    If the above one creates any issue, please try the following code:

    add_filter( 'wpmu_validate_blog_signup', 'wpmu_validate_blog_signup_cb' );
    function wpmu_validate_blog_signup_cb( $result ) {
    $current_site = get_current_site();
    if ( ! domain_exists( $result['domain'], $result['path'], $current_site->id) ) {
    if ( username_exists( $result['blogname'] ) ) {
    if ( ! is_object( $result['user'] ) || ( is_object($result['user']) && ( $result['user']->user_login != $blogname ) ) ) {
    $errors = $result['errors'];
    $errors->remove( 'blogname' );
    $result['errors'] = $errors;
    }
    }
    }
    return $result;
    }

    Cheers

    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.