0
I am trying to enter the form data created by the plug Contact Form 7 for my table 'wp_wpdatatable_2', I created a hook using add_action and all right, but it does not send to the bank and I do not receive the success message (infinite loop when trying to send), some advice?
Edited:
function wpcf7_do_something ($WPCF7_ContactForm) {
    global $wpdb;
    WPCF7_Submission::get_instance();   
    $numbene = $WPCF7_ContactForm->posted_data["NumerodoContrato"];
    $especie = $WPCF7_ContactForm->posted_data["Especie"];
    $descontm = $WPCF7_ContactForm->posted_data["DescontoMensal"];
    $nome = $WPCF7_ContactForm->posted_data["nome"];
    $file645 = $WPCF7_ContactForm->posted_data["file-645"];
    $file646 = $WPCF7_ContactForm->posted_data["file-646"];
    $file647 = $WPCF7_ContactForm->posted_data["file-647"];
    $wpdb->insert ('wp_wpdatatable_2', array(
        'NumerodoContrato' => $numbene,
        'especie' => $especie,
        'descontomensal' => $descontm,
        'nome' => $nome,
        'anexoidentidade' => $file645,
        'anexocomprovanteresidencia' => $file646,
        'anexodocumentoextra' => $file647
    ) );  
    }
add_action("wpcf7_before_send_mail", "wpcf7_do_something", 10, 1);
Have you tried
add_action("wpcf7_before_send_mail", "wpcf7_do_something", 10, 1);? Theactionare you accessing the function? The name of the fields are correct?– Valdeir Psr
I just tried, same thing, the fields are. And yes, I used a custom plug following this tutorial https://xaviesteve.com/3298/wordpress-contact-form-7-hook-unofficial-developer-documentation-and-examples/
– felipe souza
Already tried to replace variable
$cf7for$WPCF7_ContactForm? Or else$cf7 = WPCF7_Submission::get_instance();before using it? Not forgettingglobal $wpdb;in the first line of the function– Valdeir Psr
I will update the code to make it clearer what I have done. and yes I added the global variable.
– felipe souza
Same error still, I checked to see if I was right the form variables and are right, it seems some error in sql execution, because if it was the hook, I would not be giving the loop or give error 500
– felipe souza