impress-org / givewp-snippet-library

A collection of code snippets to enhance or expand on the free Give WordPress Donation Plugin.
https://givewp.com
140 stars 90 forks source link

Add multipart/form-data in donation form #27

Closed teguh87 closed 6 years ago

teguh87 commented 7 years ago

Please help me for customizing give donation form, I Only want add multipart/form-data for uploading attachment in Form Donation. I has using some example for upload wordpress

add_action('post_edit_form_tag', 'post_edit_form_tag'); function post_edit_form_tag() { echo ' enctype="multipart/form-data"'; }

But the form still does not have multipart/form-data tag.

Please Help me!

mathetos commented 7 years ago

Hi @teguh87 one of our core Give developers ( @ravinderk ) provided this snippet for that purpose:

function give_add_multipart_tag_donation_form( $final_output, $args ) {
    $form_tag = "<form id=\"give-form-{$args['form_id']}\"";
    $final_output = str_replace( $form_tag, "{$form_tag} enctype=\"multipart/form-data\"", $final_output );

    return $final_output;
}
add_filter( 'give_donate_form', 'give_add_multipart_tag_donation_form', 10, 2 );

Try that out and let me know how it goes. Thanks!

ravinderk commented 6 years ago

@mathetos can we move code to the snippet and close this issue?

mathetos commented 6 years ago

@ravinderk I added here: https://github.com/WordImpress/Give-Snippet-Library/blob/master/form-customizations/multipart-form.php

If you have inline Docs improvements on that, that would be appreciated.