/** * Collect the donor's National ID # in the donation form. * * Fields are added as a PHP array that define the field. You can customize the * following fields: * * label: The label that will be displayed alongside the field. * placeholder: Optionally, you can display a placeholder value to be shown inside the field. * type: The type of field. Options: text, checkbox, datepicker, editor, file, multi-checkbox, number, picture, radio, select, textarea, url * priority: The priority of the field. This determines where in the form the field is displayed. * value: The current/default value of the field. * required: Whether the field is required. Set to `true` or `false`. * data_type: How the field is saved in the database. The simplest option is to use `user` as in the example below, which will automatically save the field to the user meta table. * * @param array[] $fields * @param Charitable_Donation_Form $form * @return array[] */ function ed_collect_national_id_number($fields, Charitable_Donation_Form $form) { /** * If you only want to collect a certain field on a certain campaign's * donation form, uncomment this next section and replace 1234 with the * ID of your campaign. */ // if ( 1234 != $form->get_campaign()->ID ) { // return $fields; // } $fields['national_id_number'] = array('label' => __('National ID Number', 'your-namespace'), 'type' => 'text', 'priority' => 24, 'value' => $form->get_user_value('donor_national_id_number'), 'required' => true, 'data_type' => 'user'); return $fields; }
/** * Collect the donor's National ID # in the donation form. * * @param array[] $fields * @param Charitable_Donation_Form $form * @return array[] */ function ed_collect_national_id_number($fields, Charitable_Donation_Form $form) { $fields['national_id_number'] = array('label' => __('National ID Number', 'your-namespace'), 'type' => 'text', 'priority' => 24, 'value' => $form->get_user_value('donor_national_id_number'), 'required' => true, 'data_type' => 'user'); return $fields; }