Are you having a tough time setting up our Register Helper Add On? Want to add some custom fields to your PMPro membership site but don’t know how?

In this step-by-step guide, I will do a complete Register Helper(RH) walkthrough. We will learn about code snippet plugins, navigating through the RH documentation, and set up some example custom fields of our own.

Register Helper

What is Register Helper

Register Helper is a highly customizable Add On. With it, you can set up custom checkout fields, collect specific information about your members, and add this collected data to your member’s profile.

There is a lot you can do with Register Helper. You can set up text-based custom fields. Collect telephone numbers, add a selection to your checkout page, and more. The options are (almost) endless. While this is a fantastic tool it can often seem overwhelming at first. You will need to at least be somewhat familiar with code in order to properly set up this Add On. Have a look at our Register Helper documentation, or view our coding examples for more information.

If you are still uncomfortable with the thought of coding and adding it to your site and have a Premium PMPro Membership, then why not take us up on our offer and let our Support Team add up to 5 custom fields to your site for you? Simply reach out to us over on our Member Support Area.

Video Demo


Before We Get Started

Before we dive into any coding, we will first need a couple of things in place:

  1. Install and activate Paid Memberships Pro on your website.
  2. Install and activate the Paid Memberships Pro: Register Helper Add On.
  3. Download, install and activate the Code Snippets plugin. We will be adding our code to this 3rd party plugin.
Note – We recommend trying this first on a test or staging environment. This will allow you to first test and practice this method before trying it out on your live production site. You can use Local by Flywheel to set up a free staging site.

Adding Custom Fields

Once you have installed and activated Paid Memberships Pro, Register Helper, and the Code Snippets plugin. You are ready to start coding up your custom fields.

WordPress Dashboard screenshot. Displaying Paid Memberships Pro, Register Helper, and the Code Snippets plugin.

Preparing your Code Snippet.

First, let’s go ahead and configure the Code Snippets plugin:

  1. Open up the Code Snippets plugin by selecting “Snippets” > “Add New” from the WP Dashboard.
  2. Name your code snippet. I named mine “Custom Checkout Fields”.
  3. Give your code snippet a description and (if applicable) add any tags to your code snippet.
  4. Set your code snippet to “Run snippet everywhere”. If needed, you can set your code snippet priority.
code snippet

Starting a Function

In this step, we will start configuring Register Helper. We will create a function that will run on init, a WordPress action hook otherwise known as Initialize. This action hook will ‘fire’ after WordPress has finished loading but before any headers are sent. Learn more about the init action hook here.

Below are the steps on how to start writing up your function. You can add this code to your WordPress site via the newly added code snippet of the previous step:

  1. Create a function, feel free to call it whatever you would like. I have called my function pmpro_add_fields_to_checkout.
function pmpro_add_fields_to_checkout() {
   // This is where our fields code will go.
}
add_action( 'init', 'pmpro_add_fields_to_checkout' );

  1. Add an IF Statement to your function, that checks to see if Register Helper is installed and activated. If RH is not activated, return a boolean value of false. This will prevent any errors coming up if for some reason Register Helper gets deactivated or is no longer located on your site.
function pmpro_add_fields_to_checkout() {
   // Don't break if Register Helper is not loaded
   if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
		return false;
	}
	// This is where our fields code will go.
}
add_action( 'init', 'pmpro_add_fields_to_checkout' );

  1. Create an empty fields array, $fields = array();. This is where we will create our custom fields. This is currently empty and won’t display anything if saved.
function pmpro_add_fields_to_checkout() {
   // Don't break if Register Helper is not loaded
   if ( ! function_exists( 'pmprorh_add_registration_field' ) ) {
		return false;
	}
        
	$fields = array(); //This is where our fields will go.

}
add_action( 'init', 'pmpro_add_fields_to_checkout' );

  1. Finally, go ahead and add a foreach loop. This should check each of the custom fields and then place them in a certain location of our choosing. I have set my location to ‘checkout_boxes’. One of eight default locations available. Learn more about possible Register Helper custom field locations.
function pmpro_add_fields_to_checkout(){
	//don't break if Register Helper is not loaded
	if(!function_exists( 'pmprorh_add_registration_field' )) {
		return false;
	}
	
	$fields = array();

	
	foreach($fields as $field){
		pmprorh_add_registration_field(
			'checkout_boxes',	// location on checkout page
			$field	// PMProRH_Field object
		);
	}
}
add_action( 'init', 'pmpro_add_fields_to_checkout' );

You should have something very similar to the code above. If not, feel free to copy the code gist below and add it to your Code Snippets plugin.

Nothing should happen if the code is run. This is an empty function that is ready and waiting for fields to be added to it.


Adding Fields

It is time to start adding custom fields to our code. Navigate to the $fields = array(); section of your code and under it add your first field.

We will start by making a “Company” field for members to input their Company’s name when performing a checkout. We will need to create a $fields variable and assign it three main parameters:

  1. Name – Assign the input name of the field here. This will also be used as the designated field meta key. In this case, we will use name “company”.
  2. Type of field – Select the type of field here. There are multiple field types that you can choose from. We want members to write out their company name so we will use a “text” field.
  3. An array of options – There are some options that apply to every field type, and some that are unique to specific field types. I will add three attributes to this array. Learn more about the types of array options available here.
    • Label  – This label will be added to the custom field on the frontend of the PMPro checkout page. I am using “Company” for this example.
    • Profile – Display or hide this field from the member’s profile. I have set this to true.
    • Required –  This will make the field required. I have this set to true.
Register Helper Company field

By now, you should have a membership checkout page a ‘More Information’ section and in it, a ‘Company’ field. If not, go ahead and copy the code below and add it to your Code Snippet plugin.


Adding More Fields

At this point, we have a working example of Register Helper. Now let us go ahead and add an additional two fields to this example.

The quickest way that I have found to do this is to copy the entire $fields[] = new PMProRH_Field section of code. Paste it directly under the previous field. Once done, you should have two of the same fields. Now you can edit the second field by changing the various parameters and attributes.

Paid Memberships Pro Custom Fields

In the example below, I have copied and pasted two more custom fields and changed the variables of the code so that a ‘Name of Pet’ and ‘Telephone’ field is found. Take note of the parameters and attributes of each of the newly added fields.


Summary

If you have followed along with this tutorial, you should have a Paid Memberships Pro checkout page with three, new custom fields. It can be a little tricky to wrap your head around setting up custom fields with Register Helper but don’t worry. The more you practice and become familiar with the Register Helper documentation, the better you will become at adding custom fields to your PMPro Membership site.

Feel free to use the code example as a starter for your custom fields. You can potentially be up and running in a few minutes. Copy and paste the code from this example into your Code Snippets plugin. Change a few lines of code to match what fields you’re looking to create, and you’re done.

As mentioned before, if you are totally overwhelmed by this and a Paid Memberships Pro Plus member, you’re in luck. You are eligible to let our Support Engineer team set up to 5 additional custom fields for you – at no extra cost. Get in touch with our support team for more information.

Leave a Reply

For faster support related to issues on your specific site please open a ticket in our members support area.

Your email address will not be published. Required fields are marked *