strangerstudios/pmpro-register-helper

check out page will not display fields

falconreid opened this issue · 2 comments

I had managed to get the fields to appear before, but now I cannot figure out why they are not appearing on the checkout. They DO appear in the profile (but they're appearing twice and I don't see why that is either). Below is what I've put into the pmpro-customizations/pmpro-customizations.php

I've tried using each one of these in the pmprorh_add_registration_field section:
after_username
after_password
after_email
after_captcha
checkout_boxes
after_billing_fields
before_submit_button

Author URI: https://www.paidmembershipspro.com
*/

//Now start placing your customization code below this line
/*

https://www.paidmembershipspro.com/documentation/register-helper-documentation/code-examples/

Plugin Name: Register Helper Example
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-customizations/
Description: Register Helper Initialization Example
Version: .2
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 = array();
	$fields[] = new PMProRH_Field(
	'organization',						// input name, will also be used as meta key
	'text',							// type of field
	array(
		'label'		=> 'Organization',			// custom field label
		'size'		=> 80,				// input size
		'class'		=> 'company',			// custom class
		'profile'	=> "only_admin",			// show in user profile
		'required'	=> false,			// make this field required
		'memberslistcsv' => true,
	)
		);

$fields[] = new PMProRH_Field(
	'survivor',						// input name, will also be used as meta key
	'text',							// type of field
	array(
		'label'		=> 'Survivor: Please let us know if you are a survivor. If you would like, please tell us who you lost and the date.',			// custom field label
		'size'		=> 80,				// input size
		'profile'	=> "only_admin",			// show in user profile
		'required'	=> false,			// make this field required
		'memberslistcsv' => true,
	)
);

	
//add the fields into a new checkout_boxes are of the checkout page

foreach($fields as $field)
pmprorh_add_registration_field(
'after_email', // location on checkout page
$field // PMProRH_Field object
);

	foreach($fields as $field)
	pmprorh_add_registration_field(			
	    'just_profile',				// location on checkout page// 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' );

Ok, I finally stopped using the code exactly as you displayed it in the code examples and did this instead (which worked):

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 = array();
$fields[] = new PMProRH_Field(
	'survivor',						// input name, will also be used as meta key
	'text',							// type of field
	array(
		'label'		=> 'Survivor: Please let us know if you are a survivor. If you would like, please tell us who you lost and the date.',			// custom field label
		'size'		=> 80,				// input size
		'profile'	=> true,				// show in user profile
		'required'	=> false,			// make this field required
		'memberslistcsv' => true,
		
	)
);

	//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
	);

	foreach($fields as $field)
	pmprorh_add_registration_field(
		'just_profile',				// location on checkout page
		'just_profile',				// location on checkout page
		$field						// PMProRH_Field object
	);

$fields = array();
$fields[] = new PMProRH_Field(
	'organization',						// input name, will also be used as meta key
	'text',							// type of field
	array(
		'label'		=> 'Organization*: Name of Your Organization *(Silver, Gold & Platinum Memberships)',			// custom field label
		'size'		=> 40,				// input size
		'class'		=> 'company',			// custom class
		'profile'	=> true,			// show in user profile
		'memberslistcsv' => true,
		
	)
);


//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
	);

	foreach($fields as $field)
	pmprorh_add_registration_field(
		'just_profile',				// location on checkout page
		'just_profile',				// 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' );

Thanks for sharing the fix with us. Glad to hear you resolved this.