strangerstudios / pmpro-add-name-to-checkout

Adds “First Name” and “Last Name” fields to the “Account Information” section of the Membership Checkout page when using Paid Memberships Pro.
https://www.paidmembershipspro.com/add-ons/add-first-last-name-to-checkout/
17 stars 24 forks source link

Make first/last name optional with filters. #18

Closed ronalfy closed 4 years ago

ronalfy commented 4 years ago

This PR adds two filters:

Both take booleans. true is default.

An example of the filters in use:

add_filter( 'pmproan2c_first_name_required', '__return_false' );
add_filter( 'pmproan2c_last_name_required', '__return_false' );

The following scenarios have been tested:

  1. Checkout with just first name required (for each filter combination)
  2. Checkout with just last name required (for each filter combination)
  3. Checkout with both first and last name required (for each filter combination)

Function variables are used at first instead of globals so as to not populate the global namespace until we are sure there are errors to display.