rcp_after_register_form_fields

Used to add extra form fields to the end of the registration form. Fields added here are displayed directly above the gateway selection.

Use rcp_form_errors to validate form fields.

Example:

This example shows adding a custom registration field (checkbox) and validation that sets an error if the checkbox isn't checked (using rcp_form_errors).

/**
 * Add checkbox to registration form.
 * 
 * @return void
 */
function ag_rcp_after_register_form_fields() {
	ob_start(); ?>
		<p>
			<input name="rcp_sample_required_field" id="rcp_sample_required_field" type="checkbox" checked="checked"/>
			<label for="rcp_sample_required_field">Your field label*</label>
		</p>
	<?php
	echo ob_get_clean();
}

add_action( 'rcp_after_register_form_fields', 'ag_rcp_after_register_form_fields' );

/**
 * Validate form submission and add an error if checkbox isn't checked.
 * 
 * @param array $posted Array of information sent to the form.
 * 
 * @return void
 */
function ag_rcp_form_errors( $posted ) {
	if( ! isset( $posted['rcp_sample_required_field'] ) ) {
		rcp_errors()->add( 'sample_field_required', __( 'You must check this field', 'rcp' ), 'register'  );
	}
}

add_action( 'rcp_form_errors', 'ag_rcp_form_errors' );