• Resolved flojdm

    (@flojdm)


    Hi,

    I’m using Forminator_API::add_form_entry to submit form data via a custom REST API endpoint. The data is correctly saved in the backend — I can see the submission under Forminator > Submissions, and all fields are correctly mapped.

    However, the email notifications (both admin and user confirmation messages) are not sent automatically when using this method.

    To be clear:

    • The form is configured to send an automatic confirmation email to the user (e.g. “Thanks for your request, we’ll get back to you shortly.”).
    • An admin notification is also configured.
    • These emails are not sent when submitting via the API using add_form_entry.
    • If I go to Forminator > Submissions > [Entry] > Resend Email, both the user and admin emails are sent successfully, proving that everything is mapped correctly and the configuration is working.

    This confirms that:

    • The issue is not with the form setup or email configuration.
    • The problem is that Forminator_API::add_form_entry only saves the data but does not trigger the form’s built-in email notification workflow.

    Is there a proper way to trigger the full submission process (including notifications) programmatically, or is there a recommended hook or method to manually trigger the email sending after using add_form_entry?

    Thanks in advance for your help!

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi @flojdm

    I hope you are doing well today.

    I pinged our Forminator Team to review your query and see what will be possible in this case. We will post an update here as soon as more information is available.

    Kind Regards,
    Kris

    Thread Starter flojdm

    (@flojdm)

    Hey, thanks for the quick response!

    While waiting to hear back from the dev team, I explored the plugin source code to understand how Forminator handles mail sending internally, and I managed to get everything working.

    After creating the entry with Forminator_API::add_form_entry, I manually retrieved the latest entry and invoked the internal mail handler like this:

        $result = Forminator_API::add_form_entry( $form->id, $meta );

    $entry = Forminator_Form_Entry_Model::get_latest_entry_by_form_id($form->id);

    $entry_id = $entry->entry_id;

    $forminator_mail_sender = new Forminator_CForm_Front_Mail();

    $entry = new Forminator_Form_Entry_Model( $entry_id );

    if ( empty( $entry->form_id ) || ! empty( $entry->draft_id ) ) {
    wp_send_json_error( esc_html__( 'Entry ID was not found.', 'forminator' ) );
    }
    $module_id = $entry->form_id;

    Forminator_Front_Action::$module_id = $module_id;
    Forminator_Front_Action::$module_object = Forminator_Base_Form_Model::get_model( $module_id );

    Forminator_Front_Action::$prepared_data = recreate_prepared_data( Forminator_Front_Action::$module_object, $entry );

    if ( ! Forminator_Front_Action::$module_object ) {
    wp_send_json_error( esc_html__( 'Error: Module object is corrupted!', 'forminator' ) );
    }
    Forminator_Front_Action::$module_settings = method_exists( Forminator_Front_Action::$module_object, 'get_form_settings' )
    ? Forminator_Front_Action::$module_object->get_form_settings() : Forminator_Front_Action::$module_object->settings;
    Forminator_CForm_Front_Action::check_fields_visibility();

    $module_object = Forminator_Base_Form_Model::get_model( $module_id );
    $forminator_mail_sender->process_mail( $module_object, $entry );

    return ['error' => false];

    This allowed me to simulate the full frontend submission flow and trigger email notifications as expected (both to the admin and the user). Everything works perfectly now.

    Hope this helps someone else in the meantime!
    Let me know if you’d like a cleaner utility function for this in a future release.

    Best regards,

    Plugin Support Kris – WPMU DEV Support

    (@wpmudevsupport13)

    Hi again @flojdm

    To give an idea we can suggest that you need to create an object for this class Forminator_CForm_Front_Mailand call the function process_mail with the required arguments for sending the mail.

    Example:

    $forminator_mail_sender = new Forminator_CForm_Front_Mail();
    $forminator_mail_sender->process_mail( Forminator_Front_Action::$module_object, $entry, $submitted_data );

    Kind Regards,
    Kris

    Plugin Support Nithin – WPMU DEV Support

    (@wpmudevsupport11)

    Hi @flojdm,

    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.

    Best Regards,

    Nithin

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

The topic ‘Emails not triggered when using Forminator_API::add_form_entry’ is closed to new replies.