Introductory Pricing: Save 50% on your first year of any plan. Use coupon code:

FIRSTYEAR50

  • Log In
  • Welcome
  • Features
  • Pricing
  • Documentation
  • Case Studies
  • Add Ons
  • Support
  • Learn
  • Events
  • Blog
  • Contact

Log In

Join Now | Lost Password?
Skip to content
Paid Memberships Pro WordPress Membership Plugin
  • Log In
  • Choose a Plan
  • Features
    • PMPro Platform
      • Plugin Features
      • Restrict Access
      • Register Members
      • Subscriptions
      • All Features
    • Payment Gateways
      • Stripe
      • PayPal Express
      • Paystack
      • CCBill
      • All Gateways
    • Add Ons
      • Integrations
      • Free Add Ons
      • Standard Add Ons
      • Plus Add Ons
      • All Add Ons

    Launch a Free Demo
    Explore PMPro in action with your own private demo site—preloaded with members, protected content, and premium Add Ons.

    Try PMPro Now
  • Use Cases
    • Associations
    • Blog and News
    • Communities
    • Courses
    • Directories
    • Paid Newsletters
    • Private Videos
    • Podcasting
  • Documentation
    • Download & Install
      • Download PMPro
      • Install Add Ons
      • Memberlite Theme
      • Setup WordPress
      • Staging Sites
      • Support
    • Initial Setup
      • Customize Pages
      • Payment Settings
      • Restrict Content
      • Membership Levels
      • Member Emails
      • User Fields
    • More Docs
      • Shortcodes & Blocks
      • Design Settings
      • Page Builders
      • Reporting
      • For Developers
      • All Docs

    Get your membership site up and running with Kim's help.

    Watch Initial Setup
  • Community
    • Engage & Learn
      • Upcoming Events
      • Courses
      • Videos
      • Step-by-Step Guides
      • Join Slack
      • Get Support
    • Blog
      • Case Studies
      • Product Comparison
      • Code Recipes
      • Release Notes
      • Migration Guides
      • All Blog Posts

    Join the Community
    Connect with other membership site creators who use PMPro to get paid.

    Join Slack
  • Pricing
Home  >  Blog  >  Restrict User Login for Members Only

Restrict User Login for Members Only

Estimated reading time: 3 minutes

TweetFacebookLinkedIn

While some membership sites want to grow and attract as many people as possible to sign up, others are a bit more closed off and private.

What kind of private sites? I’m talking about internal sites for a company or an invite-only site that requires the admin to create your account.

Because let’s face it, sometimes members expire, cancel, or you proactively remove their access. For these users, while they still have a WordPress account, they don’t have a membership. They can log in, but they can’t access anything.

This recipe post shows you two method to restrict user login for anyone without an active membership level or valid email address.

This is especially helpful for a site that is totally locked down for members only, where you only allow public access to the homepage and login screens.

Restrict User Login For Members Only

Table of contents

  • Code Recipe #1: Restrict User Login to Active Members
  • Code Recipe #2: Require Confirmed Email Address to Log In

Code Recipe #1: Restrict User Login to Active Members

This code recipe restricts user login attempts for any user that is not an active member of your WordPress site. Once this recipe is in place, any user that does not have a membership level will fail to authenticate. This is a very powerful recipe, so please use it with caution.

While there are definite reasons to restrict user login in this way, this approach is also very limiting. For example, the login restrict code also blocks users who want to renew an expired or cancelled membership.

As an alternative, consider the second recipe in this post that is less heavy-handed. The bonus recipe restricts user login for users that have not confirmed their email address (requires the Email Confirmation Add On).

Note: Please use this recipe with caution as it is a very heavy-handed approach to blocking access for your site. As long as all of your content is correctly protected, a user without a membership level will not be able to view anything private. Also, note that a user with a previous membership level that is trying to log in as part of the checkout process will also be blocked. We suggest adding a message to your login page that logins will be blocked unless you have an active membership.

Code Recipe #2: Require Confirmed Email Address to Log In

For a less heavy-handed approach, this recipe specifically limits login attempts if the user has not validated their email address when using the Email Confirmation Add On.
*Note- At this time users will not receive a warning message explaining why they’re unable to log in if you’re using the PMPro login page.

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

Kim Coleman

Author: Kim Coleman

Kim Coleman is the co-founder of Paid Memberships Pro, the most trusted membership platform, which powers over 90,000 membership sites worldwide. With over two decades of experience in development, management, and marketing, Kim plays a pivotal role in shaping the product and guiding the team.

She specializes in content creation, video tutorials, and frontend development for the core open-source plugin and its various Add Ons, helping businesses of all sizes build and grow their membership sites.

View more articles by Kim Coleman »

Free Course: Membership Site Development—The Basics

Develop a deeper understanding of membership site development in this beginner-level course. Learn how to make your site work better, save yourself time and money, and improve your site's performance.

Take Free Course Now
Featured Image for Membership Site Development Course: The Basics


Was this article helpful?
YesNo
Tagged: login link, restrict, restrict membership. Posted in Code Recipes, Premium Code Recipes. Bookmark the permalink. Last updated: November 23, 2022.
Post navigation
← How to Grow Association Membership Using Social Proof
How to Create a Conditional Main Menu for Your Members in WordPress →

Paid Memberships Pro is recommended by our customers and users

Plugin Reviews

4.3 out of 5

G2

4.8 out of 5

Capterra

5 out of 5

We’re 100% GPL

Our plugin's code is not obfuscated, runs on as many sites as you want and can be customized to fit your project's needs. We just ask that you follow the GPLv2 guidelines by applying the GPLv2 license to any altered or unaltered version of PMPro that you distribute. License Details »

GPL v2

Recent Articles and Updates

  • Featured image for code recipe 'Customize Login Error Messages to Boost Account Security'
    Customize Login Error Messages to Boost Account Security
  • Banner for Memberlite v6.0
    Introducing Memberlite v6.0
  • Screenshot of featured image for 'Capture User Fields for Google Analytics Integration Add On' code recipe post
    Capture User Fields as User Properties for Reporting in Google Analytics Integration Add On

Platform

  • Pricing
  • Features
  • Product Comparison
  • Reviews
  • Case Studies
  • Screenshots
  • Videos
  • Step-by-Step Guides

Use Cases

  • Associations
  • Blog & News
  • Community
  • Courses
  • Directory & Listing
  • Paid Newsletter
  • Podcast
  • Videos

Add Ons

  • Free
  • Standard
  • Plus
  • Admin
  • Integration
  • Payment
  • Third Party
  • View All

Get Help

  • Support
  • Documentation
  • Download & Install
  • Hosting
  • Developers
  • Blog
  • Slack Community
  • Contact Us

Company

  • About Us
  • Events
  • Brand Assets
  • Affiliates
  • Accessibility Statement
  • Sitemap
  • Privacy Policy
  • Terms of Service
Join Us On

© 2025 Paid Memberships Pro™. Paid Memberships Pro is a trademark of Stranger Studios, LLC. All Rights Reserved.

Open Office Hours: Ask Me Anything with Jason and Andrew • Thursday, May 15th at 11am ET. SEE DETAILS ▸