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:
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.
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.
Related Articles
Roundup of WordPress ecosystem #1 – January 2017
After writing the article "Overview of the WordPress Community in 2016" and getting feedback for the article on various platforms, I decided to continue writing them, but I changed its name into "Roundup of WordPress ecosystem". This is the first article from a monthly series that will showcase what happened around the whole ecosystem in […]
Continue ReadingRoundup of WordPress ecosystem #2 – February & March 2017
There were two interesting months within the WordPress ecosystem with events that are here to impact the course and development of the platform. We saw WordPress getting important security updates and a brand new design for the plugin repository and also witnessed to a significant acquisition. With this being said, let's dive into the summary […]
Continue ReadingHow to Password Protect Content, Posts, and Categories in WordPress
There are many use cases for password-protected content in WordPress. For example, you might be a content creator who wants to monetize premium content in the form of subscriptions or memberships. As with everything related to WordPress, password-protecting posts doesn’t have to be difficult. If you’re wondering how to password-protect WordPress content, posts, and even […]
Continue Reading
I am using “Theme My Login” and network activated this plugin, but users will still be redirect to the main site for registration.
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.