pmpro-register-helper icon indicating copy to clipboard operation
pmpro-register-helper copied to clipboard

Add field location at pmpro_checkout_after_tos_fields action hook

Open ipokkel opened this issue 2 years ago • 0 comments

Is your feature request related to a problem? Please describe. There is no current location for RH fields at the relatively new pmpro_checkout_after_tos_fields action hook. We should consider adding this as a location for Register Helper.

Describe the solution you'd like Have a after_tos_fields location for Register Helper to add registration fields to, e.g. pmprorh_add_registration_field( 'after_tos_fields', $field );

Describe alternatives you've considered Add the location for Register Helper with custom code in a customization plugin.

if ( ! function_exists( 'pmprorh_pmpro_checkout_after_tos_fields' ) ) {
	function pmprorh_pmpro_checkout_after_tos_fields() {
		global $pmprorh_registration_fields;

		if ( ! empty( $pmprorh_registration_fields['after_tos_fields'] ) ) {
			foreach ( $pmprorh_registration_fields['after_tos_fields'] as $field ) {
				if ( is_a( $field, 'PMProRH_Field' ) && pmprorh_checkFieldForLevel( $field ) && ( ! isset( $field->profile ) || $field->profile !== 'only' && $field->profile !== 'only_admin' ) ) {
					$field->displayAtCheckout();
				}
			}
		}
	}
	add_action( 'pmpro_checkout_after_tos_fields', 'pmprorh_pmpro_checkout_after_tos_fields' );
}

https://gist.github.com/ipokkel/b127705f8a91dcb5920f3cb8da920fca

Additional context

Adding this location allows developers to add a registration field after the TOS fields and before the captcha location.

Ticket (moderators only): #416912

ipokkel avatar Apr 22 '22 04:04 ipokkel