• Resolved yberges

    (@yberges)


    hello

    1 i create a form with forminator with an hidden field and value {adresse_mail_de_contact}
    2 i add it in article with an acf field adresse_mail_de_contact

    my goal is to remplace admin email by adresse_mail_de_contact value

    i create a a function

    add_filter( 'forminator_custom_form_mail_admin_recipients', 'wpmudev_change_admin_email_recipient', 10, 4 );
    function wpmudev_change_admin_email_recipient( $recipients, $custom_form, $data, $entry ) {

    // Récupérer l'ID du formulaire
    $form_id = is_object( $custom_form ) && isset( $custom_form->id ) ? $custom_form->id : 0;

    // Filtre sur le formulaire spécifique
    if( $form_id != 37463 ) {
    return $recipients;
    }

    // Récupérer l'ID de la page/article
    $post_id = 0;

    if( isset( $_REQUEST['page_id'] ) ) {
    $post_id = intval( $_REQUEST['page_id'] );
    } elseif( isset( $_POST['page_id'] ) ) {
    $post_id = intval( $_POST['page_id'] );
    } elseif( isset( $_SERVER['HTTP_REFERER'] ) ) {
    $post_id = url_to_postid( $_SERVER['HTTP_REFERER'] );
    }

    if( $post_id > 0 ) {
    $email_contact = get_field( 'adresse_mail_de_contact', $post_id );

    // Vérifier que l'email est valide
    if( !empty( $email_contact ) && is_email( $email_contact ) ) {
    // Remplacer tous les destinataires par l'email du champ ACF
    $recipients = array( $email_contact );
    }
    }
    return $recipients;
    }

    But doesn’t works, what i doing wrong ?

    regards

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support Amin – WPMU DEV Support

    (@wpmudev-support2)

    Hello @yberges

    Hope you are doing well today.

    You will have to use forminator_prepared_data and forminator_custom_form_submit_before_set_fields to get the posted data and set it in the prepared data and Forminator_CForm_Front_Action::$info[‘field_data_array’].

    I’m afraid that since custom coding is out of scope of our support, we can’t help you much, in case you need further help, you’ll need to hire a developer to provide the required custom code for you. WordPress provides a jobs directory here https://jobs.wordpress.net/, if you need further advice about it, feel free to email [email protected].

    Subject: ATTN: WPMU DEV support – wp.org

    Best Regards
    Amin

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @yberges,

    Since we haven’t heard from you for a while. I’ll mark this thread as resolved for now. Please feel free to re-open this thread if you need any further assistance.

    Regards,

    Nithin

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Replace admin email recipient by acf email value’ is closed to new replies.