Enable WordPress User Registration on a Subsite Only

When you have WordPress Multisite active, all users are shared between all blogs because the wp_users table is the same for all blogs.

By default, it’s simply not possible to enable WordPress user registration on a subsite only. To go around this, first thing we need to do is enable registration in our network admin:

enable wordpress user registration on a subsite only

Next we need a small plugin. Simply create a new php file called multisite-block-registrations.php and add the code bellow to it:

We’ll use two filters:

  • wp_signup_location – this filters modifies the default WordPress redirect from /wp-login.php?action=register to /wp_signup.php
  • before_signup_header – we’ll use this action to redirect all users from /wp_signup.php to the homepage of the site they accessed it from.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
<?php
/** * @package Multisite_Block_Default_Registration * @version 1.0 */
/*
Plugin Name: Multisite Block Default Registration
Plugin URI: http://www.cozmoslabs.com
Description: Block default registration page in multisite. Other registration pages may be used. This should be activated network wide.
Author: Cristian Antohe
Version: 1.0
Author URI: http://www.cozmoslabs.com
*/
 
add_filter( 'wp_signup_location', 'mbdr_current_blog_home' );
function mbdr_current_blog_home($location)
{ return get_site_url();
}
 
add_action('before_signup_header', 'mbdr_redirect_signup_home');
function mbdr_redirect_signup_home(){ wp_redirect( get_site_url() ); exit();
}

Go a head an activate this plugin network wide.

Add a Registration form on a particular subsite

Now that you can’t register on any site in the network since we’re redirecting them to the homepage of the current site, we need to enable registration on a particular subsite only.

We’ll do that using the free Profile Builder plugin and the [wppb-register] shortcode.

enable wordpress user registration on a subsite only

That is all. You can take this further as to adding a login page using [wppb-login] shortcode or widget.

As for limitations, this won’t work if you enable user registration + blog creation. Profile Builder currently doesn’t support blog creation.

Subscribe to get early access

to new plugins, discounts and brief updates about what’s new with Cozmoslabs!

Source: https://www.cozmoslabs.com/56583-enable-wordpress-user-registration-subsite/


You might also like this video