Skip to content

Instantly share code, notes, and snippets.

@rickalday
Created October 27, 2025 20:43
Show Gist options
  • Select an option

  • Save rickalday/0eed7270be45499a8d1c6c147cc16840 to your computer and use it in GitHub Desktop.

Select an option

Save rickalday/0eed7270be45499a8d1c6c147cc16840 to your computer and use it in GitHub Desktop.
Create a year dropdown field in a GiveWP form
<?php
function getYears(): array
{
$startYear = 1970;
$currentYear = date('Y');
return range($startYear, $currentYear);
}
add_action('givewp_donation_form_schema', static function (Give\Framework\FieldsAPI\DonationForm $form) {
$field = Give\Framework\FieldsAPI\Select::make('grduation_year')
->options(...getYears())
->emailTag('graduation_year');
$form->insertAfter('email', $field);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment