Customizing form field content based on URL query parameters like utm_source #6121
-
I am wanting to modify the donation form based on URL query parameters like utm_source=campaign1. These would be two added text/graphics fields and modifying the donation ask array (multi-level donation amounts). The backend would have a custom post type (CPT) with Advanced Custom Fields to provide the input to the form (with the set of URL query to match, and the various data mentioned below). So I need to: a) add two text/graphic (HTML) fields programmatically, and then populate them with the backend CPT values Do your hooks and internal API support that? If yes, what hooks would those be? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @bsabalaskey GiveWP recently released a Fields API for dynamically adding fields to the donation forms. With that, you can hook into different template locations within the form and register a new custom field - GiveWP will take care of the rest. See // Add field(s) before payment gateways
add_action( 'give_fields_payment_mode_before_gateways', function( $collection ) {
// Append a required text field with the name myTextField
$collection->append(
give_field( 'text', 'myTextField' )
->label( 'My Text Field' )
->required() // Could instead be marked as readOnly() (optional)
->helpText( __( 'This is my custom text field.' ) )
);
}); |
Beta Was this translation helpful? Give feedback.
-
Also, the donation levels are stored as a serialized array in the |
Beta Was this translation helpful? Give feedback.
Hey @bsabalaskey
GiveWP recently released a Fields API for dynamically adding fields to the donation forms. With that, you can hook into different template locations within the form and register a new custom field - GiveWP will take care of the rest.
See
give/src/Framework/FieldsAPI/
for supported field types.See
give'src/Form/LegacyConsumer/TemplateHooks.php
for supported form template locations.