Setting up a members-only area in a WordPress multi-site installation

Setting up a members-only area in a WordPress multi-site installation

Goal: Set one site within an existing multi-site install so that only identified users could visit that site and view the content.

My client has about 2000 employees and wanted to create a private area on an existing WordPress Multi-site install.  We have 35 sub-directory sites within the Multi-site install.  I wanted to make it as seamless as possible for the user and as simple as possible for the administrators.

At first, I looked into the various membership plugins (s2Member, WP-Member, Membership) but they were too complicated for my needs.  I didn’t need pay portals or different levels: just yes they were members and could view or no they were not members and content is blocked.

My solution came in two parts.  First, in the WordPress Network Admin Dashboard (Super-Admin required for this)

Under Network Settings,  select radio button next to User Accounts May be Registered

In the box below, Limited Email Registrations,  key in the email domain registration ex: if your customer’s email address is steve@somedomain.com, key in somedomain.com. This prevents anyone with an email that is NOT name@somedomain.com from registering.

Once I allowed the names, I went into my Functions.PHP file and added a line of code

add_action('register_form', 'register_message');
function register_message() {
    $html = '
        <div style="margin:10px 0;border:1px solid #e5e5e5;padding:10px">
            <p style="margin:5px 0;"><strong>Online registrations are only accepted with somedomain.com email addresses.
               Please contact SomeDomain's webmaster if you have questions.</strong></p>
        </div>';
    echo $html;
}

This error message (“Online registrations are only accepted with somedomain.com email addresses. Please contact SomeDomain’s webmaster if you have questions.”) shows up when someone tries to register with an invalid email address.

To make it simpler for users to login and register from anywhere, I also added Sidebar Login which works beautifully with the WP standard registration.

Now I have a seamless members-only site where users who are already logged in can visit without having to log in a second time, users who are not logged in have the option to log in from a sidebar login widget, and users who are not registered have no access to the content.

Plugins: Members Only (http://wordpress.org/extend/plugins/members-only/) with the fix (http://wordpress.org/support/topic/members-only-options-not-saving-for-multisite-30-blog?replies=4)

Sidebar Login (http://wordpress.org/extend/plugins/sidebar-login/)

 

Enhanced by Zemanta

Leave a Reply

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

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>