• I inserted this snippet in the functions.php file to add a custom field named “Ricorrenza in memoria” to the donation form.
    Also I would like this field to be added only to the donation form with ID=“21710”.
    Below is the code, but the additional field does not appear

    // Nuovo campo Ricorrenza in memoria per donazione, aggiunto solo al modulo con ID=21710
    add_action( 'give_fields_donation_form_after_personal_info', function( $form_id ) {
    // Controlla se l'ID è quello desiderato (21710)
    if ( $form_id == 21710 ) {
    give()->form_field_manager->add_fields(
    'give_donation_form',
    [
    [
    'type' => 'text',
    'name' => 'ricorrenza_in_memoria',
    'label' => __( 'Ricorrenza', 'give' ),
    'placeholder' => __( 'Inserisci qui la ricorrenza', 'give' ),
    'description' => __( 'Inserisci qui la ricorrenza', 'give' ),
    'attributes' => [
    'required' => true,
    'minlength' => 2,
    'maxlength' => 300,
    ],
    'show_in_receipt' => true,
    'store_as_donor_meta' => true,
    ]
    ],
    $form_id
    );
    }
    }, 10, 1);

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • I think I’ve seen somewhere they use post ID’s I’m not 100% sure but you can try :

    “If you want to target a specific form?you can pass the form or post id as a conditional. The example below targets a form with the ID. Note that this will only work for single GiveWP form pages, not when the form is output via the shortcode.”

    Bottom of https://givewp.com/documentation/developers/changing-form-label-text/ shows how to target a specific form.

    function give_fields_donation_form_after_personal_info($post) {
    global $post;

    if ( $post->ID == '21710' ) {
    }
    }
Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.