Custom Fields
-
Hi,
I’m trying to customize the form for one of the gateways from my functions.php file.
To do so I’ve use remove_action and add_action to get the form fields as I want and it looks fine. The problem comes with the form validation.Using the filter ‘give_purchase_form_required_fields’ I’ve set the require fields:
`function custom_give_form_required_fields( $required_fields, $form_id) {
$payment_mode = give_get_chosen_gateway( $form_id );
if($payment_mode == ‘mypayment’ || $payment_mode == ‘offline’)
{
$required_fields[‘give_last’] = array(
‘error_id’ => ‘invalid_last_name’,
‘error_message’ => __( ‘Please enter your last name.’, ‘cooper-child’ )
);$required_fields[‘card_address’] = array(
‘error_id’ => ‘invalid_card_address’,
‘error_message’ => __( ‘Please enter your address for billing purposes.’, ‘cooper-child’ )
);$required_fields[‘user_dni’] = array(
‘error_id’ => ‘invalid_user_dni’,
‘error_message’ => __( ‘Please enter your DNI / NIF’, ‘cooper-child’ )
);$required_fields[‘user_phone’] = array(
‘error_id’ => ‘invalid_user_phone’,
‘error_message’ => __( ‘Please enter your phone’, ‘cooper-child’ )
);$required_fields[‘card_zip’] = array(
‘error_id’ => ‘invalid_zip_code’,
‘error_message’ => esc_html__( ‘Please enter your zip / postal code.’, ‘give’ )
);
}return $required_fields;
}
add_filter( ‘give_purchase_form_required_fields’, ‘custom_give_form_required_fields’ );`But when I send an empty form it only shows the zip and the terms of use errors.
In addition, I want to show those new fields in the different reports and in the donants info, is this possible using the filters and actions?
Thanks
The topic ‘Custom Fields’ is closed to new replies.