Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimcoleman/75022e78bc2b245b6265127519f67248 to your computer and use it in GitHub Desktop.
Save kimcoleman/75022e78bc2b245b6265127519f67248 to your computer and use it in GitHub Desktop.
Only require Email Address to create user.
<?php
/**
* Only require Email Address to create user.
* This recipe requires Paid Memberships Pro and the Register Helper Add On.
*
* Note: this recipe depends on a future patch to Paid Memberships Pro core plugin in order to function.
*/
/**
* Hide the Account Information Section
*/
function simple_checkout_hide_account_information_section( $skip_account_fields, $current_user ) {
if ( empty( $current_user->ID ) ) {
$skip_account_fields = 1;
}
return $skip_account_fields;
}
add_filter( 'pmpro_skip_account_fields', 'simple_checkout_hide_account_information_section', 10, 2 );
/**
* Don't load any of the Billing Information fields.
*/
function simple_checkout_remove_billing_address_fields( $include ) {
return false;
}
add_filter( 'pmpro_include_billing_address_fields', 'simple_checkout_remove_billing_address_fields' );
/**
* Unset required account fields, we'll use Register Helper to require our new fields.
*/
function my_required_user_fields( $pmpro_required_user_fields ) {
unset( $pmpro_required_user_fields['username'] );
unset( $pmpro_required_user_fields['password'] );
unset( $pmpro_required_user_fields['password2'] );
unset( $pmpro_required_user_fields['bconfirmemail'] );
return $pmpro_required_user_fields;
}
add_filter( 'pmpro_required_user_fields', 'my_required_user_fields', 10, 2);
/**
* Register Helper Required Fields
*/
function simple_checkout_email_only_signup_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(
'bemail',
'text',
array(
'label' => 'Email Address',
'profile' => true
)
);
$fields[] = new PMProRH_Field(
'bconfirmemail_copy',
'hidden',
array(
'label' => '&nbsp;',
'value' => '1',
)
);
pmprorh_add_checkout_box( 'account', 'Account Information');
//add the fields into a new checkout_boxes are of the checkout page
foreach ( $fields as $field ) {
pmprorh_add_registration_field(
'account',
$field
);
}
}
add_action( 'init', 'simple_checkout_email_only_signup_pmprorh_init' );
@laurenhagan0306
Copy link

This recipe is included in the blog post on "Increase Conversion Rates with a Simplified Checkout" at Paid Memberships Pro here: https://www.paidmembershipspro.com/increase-conversion-rates-with-a-simplified-checkout/

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