2

As a network admin in multisite configuration, I have the option to enable or disable the user registration \ site registration. is there any way i can enable the user registration on s single sub site , not on all sites.

In my WP setup, I have a main blog which is managed by me and I dont want user to register here. i have a another blog installed on sub directory dedicated for forum. I would like to enable user registration here, so that user can use the forum

  • Did you try the settings at the individual site level? That should work independently – Maruti Mohanty Nov 26 '13 at 14:06
  • 1
    There is no option to set user registration in individual sites – acr Nov 26 '13 at 14:27
  • oh yes you are right... My bad :) – Maruti Mohanty Nov 26 '13 at 14:45
  • As you have found WordPress on its own doesn't allow sub-site registration and many of the plugins expect the user to belong to the main site at least before granting other sub-sites. There is a new plugin network-subsite-user-registration which does want you are after. – Justin Mar 19 '17 at 21:31
1

The multisite setup allows you to enable and disable user registration at the network level but if you see the database it store the value in the wp_options tables for each site.

So we can try the below and see if this work.

Use the below code in the functions.php file.

function wpse_enable_user_registration( $blog_id = 1 ) {
    switch_to_blog( $blog_id );
    // Fetching the present option
    $user_registration_option = get_option( 'users_can_register', 0 );

    if( '0' == $user_registration_option )
        $site_registration_option = update_option( 'users_can_register', 1 );

    restore_current_blog(); // Switches back to the original blog

    return $site_registration_option;
}

If the updation is successful, you will get true else false

Now you can use the function to enable any subsites in the MU setup by passing the sub sites id to the function in place of $blog_id

  • Does this need to hook into anything? – Jen Nov 26 '13 at 15:25
  • 1
    Depends on your requirement. You can hook it or else you can use it as a function passing the blog id – Maruti Mohanty Nov 26 '13 at 15:29
  • 1
    Seems to me this does the same thing as changing the "Users can register" value in the Network Admin -> Edit Site -> Settings Tab. That does not appear to have any effect if the global registration setting is turned off. – Rob Apr 10 '14 at 20:02
1

Multisite adds a filter for get_option('users_can_register') calls in ms-functions.php users_can_register_signup_filter. This filter circumvents any blog-level settings you try to implement.

/**
 * Check whether users can self-register, based on Network settings.
 *
 * @since MU
 *
 * @return bool
 */
function users_can_register_signup_filter() {
    $registration = get_site_option('registration');
    if ( $registration == 'all' || $registration == 'user' )
        return true;

    return false;
}
add_filter('option_users_can_register', 'users_can_register_signup_filter');

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.