Enable WordPress User Registration on a Subsite Only

enable wordpress user registration on a subsite only
Cristian Antohe
Last Updated: 19/04/16

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.

2 thoughts on “Enable WordPress User Registration on a Subsite Only

    I am using “Theme My Login” and network activated this plugin, but users will still be redirect to the main site for registration.

    Reply

    What this mini plugin does is simply blocks the default signup registration form. So when users click the Theme My Login registration form they get redirected to the homepage.

    What you need is remove the registration link in Theme My Login, and under it, place a link to a register page created with the [wppb-register] shortcode from Profile Builder.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.