612-293-8629 HELLO@THEMIGHTYMO.COM

I am using the Members plugin for the first time, and it is awesome.

The only downside that I have found thus far is in the documentation.

Below I outline how to use the plugin’s functionality in a custom WordPress page template to restrict the contents to a certain role.

Step 1: Install and activate the plugin.
Step 2: Create a role. In our case, we will call the role, “Staff”.
Step 3: Create a capability for that role. In our case, we will create a capability called, “view_staff_member_pages”.
Step 4: Add a user to the “Staff” role.
Step 5: Insert the following code into your template file:

<?php 
if ( function_exists( 'members_check_for_cap' ) && members_check_for_cap( 'view_staff_member_pages' ) ) { 
  if ( current_user_can('view_staff_member_pages') ) { 
    // DO STUFF IF THE CURRENT USER IS A STAFF MEMBER
  } else {
    echo '<a href="' . wp_login_url(get_permalink()) . '">Login</a> to view this content.';
  }
}
?>

That’s it! I hope this helps.

PHONE, EMAIL, TEXT

We love to communicate: phone, email, text, Facebook, Twitter, LinkedIn, you name it.

LOCATIONS

PAYMENTS ACCEPTED

Call Now

Enroll in Our Free Beginner WordPress Class - delivered to your Email Inbox!

Become a WordPress superstar for FREE in only minutes a day!  Our free Beginner WordPress Email Class will be delivered to your inbox!

Learn More 

You Have Successfully Enrolled! Prepare For Amazing!