• Skip to primary navigation
  • Skip to main content

RocketGeek

Home of WP-Members, The Original WordPress Membership Plugin

  • WordPress Plugins
    • WP-Members
      • FAQs
      • Quick Start
      • Documentation
      • Extensions
    • Advanced Options
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Download Protect
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Invite Codes
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • MailChimp Integration
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • PayPal Subscriptions
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Salesforce Web-to-Lead
    • Security
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Text Editor
      • Purchase the Plugin
      • Get the Pro Bundle
    • User List
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • User Tracking
      • Documentation
      • Purchase the Plugin
      • Get the Pro Bundle
    • Memberships for WooCommerce
    • WordPass
  • Blog
    • Basics
    • Tips and Tricks
    • Filters
    • Actions
    • Code Snippets
    • Shortcodes
    • Design
    • Release Announcements
  • Store
    • Cart
    • Checkout
  • Contact
  • Log In
  • Show Search
Hide Search
Home » Archives for wpmem_admin_block_meta_save

wpmem_admin_block_meta_save

Restrict a post or a page to a specific user role

Chad Butler · Jun 20, 2023 ·

While the core plugin restricts posts to logged in users, and can also create memberships for other types of restriction, sometimes you may wish to restrict content to a user role.

This custom code snippet can be copy-pasted to wherever you store custom code and will add a list of roles to the WP-Members restriction meta box in the post editor, and then will restrict the content based on those roles.

Note that this functionality is included in the WP-Members Advanced Options extension.

Continue Reading →

Restrict a post or a page to a specific user role – multiple select version

Chad Butler · Jan 7, 2015 ·

Similar to how we took the post/page restriction for specific users to a multiple select version, this post takes the restrict content by role idea and expands it to a multiple select version.

This is an extension of the ideas presented in the tutorial Restrict Content by Role with the twist that this version makes some minor changes to incorporate an HTML multi-select for selecting multiple roles for access to content.

The differences between these two code snippets is minimal, so I won’t actually repeat the concept in this post. But you should read the original version to get an understanding of what is being done and how it works.  This post will just highlight what’s different.  Continue Reading →

Add a meta box in the post editor for blocking custom post types

Chad Butler · Nov 21, 2014 ·

Users who configure to block custom post types will notice that you don’t get the meta box that WP-Members shows for blocking (or unblocking) posts and pages.  While you can still use custom fields directly for custom post blocking/unblocking at the individual post level, it’s nice to have the meta box.  So I’ve put together a code snippet for you to use to implement this on your custom post type editors.

Continue Reading →

Restrict content by user level

Chad Butler · May 16, 2014 ·

I have written code snippets before on how to restrict content by user level, but that particular code snippet is based on using categories as the user levels, with higher level users still being able to access lower level content. For example, Silver, Gold, and Platinum level users having access or not to categories of the same name.

But what if you have content that you need to block by level that is not necessarily in a category?  Or what if you are using pages that need the same level of restriction.

Here is a code snippet that will allow you to assign a “level” to any content – post or page, and then assign a user level for the users.  This example provides a working code snippet for applying a series of progressive levels (higher level users have access to lower level content).  The example begins with three generically named levels, these can be renamed and expanded or contracted as needed.Continue Reading →

Restrict Post or Page Access to a Specific User

Chad Butler · Dec 20, 2013 ·

Every once in awhile, I get a question about restricting content (either page or post) to a specific user.  There is a limited way to do that with the wpmem_securify filter, similar to the method for blocking content by category and user level.

post_meta_with_user_dropdownThis process is actually easier than blocking by levels or categories because you only need to determine three things:

  1. Is the user logged in? If not, then it is blocked regardless.
  2. If the user is logged in, but not the specified user, it is blocked and an error message is given.
  3. If the user is logged in and is the specified user, then the content is delivered.

This example will make use of a couple of new action hooks that will allow us to add a dropdown selector of users to the WP-Members post meta box.  Continue Reading →

Ready to get started?

Join Today!

© 2025 · butlerblog.com · RocketGeek is built using WordPress, WP-Members, and the Genesis Framework

  • butlerblog.com
  • WP-Members Support Subscription
  • Terms of Service
  • Privacy Policy
  • Refund Policy