person doing stunts on bike

GravityForms User Registration with Restrict Content Pro

This blog post provides instructions for outdated versions of Restrict Content Pro and Gravity Forms. We will be updating this post soon. In the meantime, if you need help implementing this functionality, send us a message.

It’s no secret that the team here at iWitness Design is a BIG fan of Restrict Content Pro. We use it on many client sites and even have several add-ons that we’ve built for it over on Skillful Plugins.

One of the reasons we love RCP so much is because of its simple interface and customizability. In many ways it’s like a framework that you can use to build any kind of membership site.

One of the ways that we help our clients is by optimizing the registration flow. Sometimes this is with a custom UI that we build (like the registration interface for StudyChurch) and sometimes it is as a simple integration with a super flexible registration system like the one that Gravity Forms offers.

In this article, I’m going to show you how to easily connect your RCP user registration to Gravity Forms.

Setting up Restrict Content Pro

There is nothing special that you need to do on the RCP side of things to make this work; simply setup your subscription levels as you normally would. Bear in mind the IDs assigned to these subscription levels as we’ll be using them when we setup our registration form.

An important note here. Using Gravity Forms for user registration bypasses all of the payment mechanisms of RCP. So my recommendation is to register the user as a free member initially and then upsell once the member is logged in.

Setting up Gravity Forms

To register new members through Gravity Forms, you will need the Gravity Forms User Registration add-on. Setup the user registration form as defined in the documentation.

Now, at the bottom of your registration form, add 2 new fields to define the meta that we will need to tell RCP that a user has registered.

  • Member Status – This is the status of the newly registered member. Use ‘free’ for free subscriptions and ‘active’ for paid subscriptions.
  • Subscription Level – This is where you will put the subscription level that the user is registering for. If there is only one level, store it in a hidden field, otherwise, you can use a dropdown or radio field here.

Now in the User Registration settings for the form, add a couple of new user meta fields to correspond with the Member Status and Subscription Level.

  • Member Status → rcp_status
  • Subscription Level → rcp_subscription_level

That’s it! You can now use all the power of Gravity Forms to handle user registration, notification, and membership approval!

Common Problems

Regarding subscription incrementation

Using Gravity Forms to register new users will not automatically increment the subscription level count in the RCP settings area. In order to do that, you can implement the following code:

   /**
     * Make RCP aware of our new subscriber
     *
     * @param $user_id
     * @param $entry
     *
     * @since  1.0.0
     *
     * @author Tanner Moushey
     */
    function iwitness_fix_rcp_count( $user_id, $entry ) {
        // make sure we have our rcp_status defined
        if ( ! $status = get_user_meta( $user_id, 'rcp_status', true ) ) {
            return;
        }

        // The RCP Set Status function triggers a lot of important actions
        // remove the status we set and reset it using the RCP function
        delete_user_meta( $user_id, 'rcp_status' );
        rcp_set_status( $user_id, $status );
    }
    add_action( 'gform_user_registered', 'iwitness_fix_rcp_count', 10, 2 );

What about paid subscriptions?

Like I mentioned earlier in this article, using Gravity Forms to handle registration does not support RCP’s payment system. So recurring paid subscriptions are not going to renew correctly. You can setup payment for subscriptions with one-time-payments using Gravity Forms, but that won’t show up in the RCP statistics.

If this piece of functionality is critical for your project, reach out to us and we can implement the custom code needed to set this up.

17279

Was this article helpful?

Sign up to get more content like this sent right to your inbox!

12 thoughts on “GravityForms User Registration with Restrict Content Pro”

  1. Pingback: Nested Forms - Using Gravity Forms as a Field Template | iWitness Design

  2. Hi.
    Just wondering if this still works in RCP 3+ ?
    The reason I’m asking is that they’ve now moved away from storing user membership info in user metadata, and now store it in custom database tables.

  3. Hi Landon,

    Thank you so much for this post.
    I’m also trying to connect Gravity form with RCP 3+ as Jim was. I’m not sure I know just what I’m doing with the code you provided. Would you be able to help?

    Thanks so much!
    Lilli

    1. Hi Lilli,
      I’d love to help. Before diving in, I’d like to reiterate that this code snippet does not support RCP’s payment system or recurring payments.

      The action gform_user_registered is triggered after the Gravity Forms User Registration plugin creates/registers a new WordPress user. We’re hooking into that action and doing the following:

      • Retrieving the RCP membership level from the form entry using the Gravity Forms rgar function.
      • Adding an RCP customer using $user_id.
      • Creating an RCP membership using both the $customer_id and the $rcp_level.

      As far as where to put it, you can either add the code to the functions.php file of your child theme or add it to a functionality plugin.

      1. Hi Landon,

        Thank you so much for your response.

        Newbie question (sorry): what fields in the code do I need to change to use for my site? I’m using a code snippet plugin.

        I really appreciate the help!

        1. Lilli,
          no problem at all. If you’re using this code snippet, then you would need to change 2 on line 12 to the ID of the Gravity Form field which returns the number value of the membership ID. You can find the ID of the field by hovering over the field in the Gravity Forms form editor.

  4. Hi, Thanks for this post, but I’m having issues with RCP3 and getting the status of a new user set to Active and not Pending. I’ve taken your snippet (https://snippets.cacher.io/snippet/9471c3cab410250ba20a) and added a line to the last section:


    $membership_id = rcp_add_membership( [
    'customer_id' => $customer_id,
    'object_id' => $rcp_level,
    'status' => 'active'
    ] );

    But my newly registered users are still showing as Pending… I would appreciate any direction you can provide here.

    (I wrote a post about combining RCP & GF years ago, https://beckydavisdesign.com/integrating-gravity-user-registration-with-restrict-content-pro/, but with the recent changes I’ve gotten lost as to how to set the status.) Thanks

    1. Hi Becky,
      the code your using looks correct to me. Try adding this code right below where you are creating the membership.


      $status = rcp_get_status( $user_id );
      rcp_log( sprintf( 'Membership status set to %s', $status ), true );

      (I know rcp_get_status is deprecated, but it will work fine for debugging)

      Then enable Restrict Content Pro’s debug. This should allow you to view (in the RCP log viewer) what your status is set to upon registration and know if the status is getting set somewhere else afterward.

Leave a Reply