Skip to content

Instantly share code, notes, and snippets.

@ideadude
Last active April 7, 2021 03:53
Show Gist options
  • Save ideadude/50604949e25a54032b653fd86791149b to your computer and use it in GitHub Desktop.
Save ideadude/50604949e25a54032b653fd86791149b to your computer and use it in GitHub Desktop.
Who referred you to our site? field for PMPro Register Helper
<?php
/*
Plugin Name: Paid Memberships Pro - Custom Register Helper Fields
Plugin URI: https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/
Description: Register Helper Fields
Version: .1
Author: Stranger Studios
Author URI: http://www.strangerstudios.com
*/
//we have to put everything in a function called on init, so we are sure Register Helper is loaded
function my_pmprorh_init()
{
//don't break if Register Helper is not loaded
if(!function_exists( 'pmprorh_add_registration_field' )) {
return false;
}
//define the fields
$fields[] = new PMProRH_Field(
'referral', // input name, will also be used as meta key
'text', // type of field
array(
'label' => 'Who referred you to our site?', // custom field label
'profile' => 'admin', // only show in profile for admins
'memberslistcsv' => true, //include in csv exports
)
);
//add the fields into a new checkout_boxes are of the checkout page
foreach($fields as $field)
pmprorh_add_registration_field(
'checkout_boxes', // location on checkout page
$field // PMProRH_Field object
);
//that's it. see the PMPro Register Helper readme for more information and examples.
}
add_action( 'init', 'my_pmprorh_init' );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "How to add a custom referral field to your membership site and how it can help you grow your business." at Paid Memberships Pro here: https://www.paidmembershipspro.com/how-to-add-a-custom-referral-field-to-your-membership-site-and-how-it-can-help-you-grow-your-business/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment