Integrating Gravity User Registration with Restrict Content Pro

Revised: 1/20/21, see addendum below
Use Case:

On the original site, the membership plugin used was pretty unwieldy, didn’t let excerpts show and we had a huge issue with spam registrations. The goals for the re-design was to still restrict content to logged in users; but allow excerpts to show to everyone, including search engines and make the registration/verification process easier.

I also needed a pretty complicated registration form, so I wanted to use Gravity Forms to build it. These are the steps I took to combine the ease of building a form with Gravity, registering new users for the site and connecting it to Restrict Content Pro membership.

  • Site needs about 80% of its content restricted from non-registered users, but we still want the excerpts to show.
  • Need users at several distinct levels –
    • Trial – full read access for a limited time
    • Member – full read access, unlimited time
    • Shopper – full read access, unlimited and see “buy now” buttons in Woo shopping cart.
  • All users are free, there is no payment – the Gravity form will not work if payment is involved in initial registration
  • All users start with a Trial 5 day subscription, but get moved to full member manually by the business office after they have been verified.
  • Plugins needed:
    • RCP (developers license)
    • Gravity Forms (developers license)
    • Registration form add-on for Gravity
  • For Shopping restrictions:
    • WooCommerce
    • WooCommerce Catalog Visibility Options (this works based on user role)

Setup Restrict Content Pro

  • Restrict>Settings
    • General – Add license key
    • Messages – These are what show up when user is not logged in or registered, premium is all that’s needed. This text can be formatted with CSS classes if desired.
    • Sign-up form and Emails – become moot, this is what Gravity is taking over
  • Restrict>Subscription Levels
    • Add a Trial subscription with a limited amount of days*
      • *Because we’re using Gravity to add the user, the date limit doesn’t work here. See Gravity User Registration notes.
    • Add a regular subscription, unlimited – both of these are Subscriber level
    • Added a 3rd level for U.S. shoppers, role of customer (from WooCommerce)

Setup Gravity registration form – add RCP fields in the add-on section.

  • Forms>new form
    • Create user registration form with desired fields
    • At the end of the form, add 3 hidden fields
  • RCP Status, Default value ‘active’ (status of free works, but does not allow the users to actually see content once logged in!) *See addendum

RCP sttus

  • GF active statusSave form, make sure it’s active (green in list view) and add a Confirmation
  • Under Notifications, make sure Admin notification is turned on as well; this is what will send you the form. You can add an additional thank you email here if you want.
  • Forms>User Registration
    • Action is Create user, assign the form you just created
    • Assign the User settings
    • Add the User Meta, this is the 3 hidden fields you added.
    • This is where you can force user activation via email as well. This single check box saves the business office from having to weed through thousands of junk registrations. If the account wasn’t activated by a human with a real email address, then it doesn’t exist in the system and the form can be ignored.User registration settings

Activate users procedure

  • A user fills out the registration form and the office gets the form via the Admin notification.
  • Until the user activates the account, they do not show up in the Users or Members list, making verifications easier for the business office and spam registrations a non-issue.
  • Once the account shows up, the office goes through their verification procedure and either deletes the user account or upgrades them to full membership

I originally wrote this article in 2015 and have had this active on my site all these years. Last year, RCP went through a major upgrade, they separated Memberships from Users and created a separate Customers table as well. I’m sure RCP had a good reason for all of this, but in my case the changes broke our trial system. Because RCP_status was deprecated as a function, new users coming in through the registration form were coming in as Trial Pending, not Active. This defeated the purpose, Trial users are not able to read restricted articles until their status in Active, something the ladies in the office have been scrambling to keep up with and change manually.

I did a lot of research on this and tried to come up with a function that would automagically update these new Trial members to Active as soon as they activated their account. I tried the solution presented in this article, but was unable to get the gform_user_registered function to work. When I get stuck like this, I turn to the folks at AlphaParticle for help. The solution turned out to be to ignore what GF was doing and go straight to the issue, Pending members need to always be changed to Active. This function says, find the membership, get their status, and if it’s Pending, change it to Active. This is written as a simple plugin file.

<?php /** * Plugin Name: RCP status fix 
* Description: Fix member import status, set to active 
* Author: Becky Davis 
* Version 1.0 
* Author URI: 
* fix changes in RCP 3+ - set status to active
function bd_add_rcp_membership_status( $membership_id, $data ) { 
        $membership =rcp_get_membership( $membership_id); 
        $status= $membership->get_status();

	if('pending' == $status) {

add_action( 'rcp_new_membership_added', 'bd_add_rcp_membership_status', 10, 2 );