Paid Memberships Pro: Company Name Field at Checkout
Adds an optional "Company" field to the Paid Memberships Pro checkout and member profile, saved with the member's account.
Opens WPIDE on
Code
add_action( 'init', function () {
if ( ! function_exists( 'pmpro_add_user_field' ) || ! function_exists( 'pmpro_add_field_group' ) || ! class_exists( 'PMPro_Field' ) ) {
return;
}
pmpro_add_field_group( 'wpide_company', 'Company details' );
pmpro_add_user_field( 'wpide_company', new PMPro_Field( 'company', 'text', array(
'label' => 'Company',
'profile' => true,
'required' => false,
'size' => 40,
) ) );
} );
Notes
Uses PMPro's user fields API (PMPro 2.9 or newer). Set required to true to make it mandatory; the value is stored in the "company" user meta.
How to add this snippet
- Install WPIDE on your WordPress site (it is free) and open Code Snippets.
- Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
- It is added inactive: review the code and settings, then switch it on.