Ninja Forms - execute/process E-Mail Action through Code

46 Views Asked by At

We made an extension to implement our own payment into the ninja forms solution, with the response from the api we get back the paid status if the payment is confirmed or cancelled. now we would like to process an email action from ninja forms only if the payment has been confirmed. since we get the api response after the form has been sent and update the paid status field in the form, we have to process it manually. We are having trouble with executing the process function for the confirmation email after we get back the paid status.

as of right now, the code for processing the email looks like this:

                        $actions = Ninja_Forms()->form($formData['extra']['_form_id'])->get_actions();
                        foreach($actions as $action){
                            if($action->get_setting('label') == 'Bestätigungsmail'){
                                $nfRoutesSubmissions = new NF_Routes_Submissions();
                                $action_settings = $nfRoutesSubmissions->process_merge_tags((array) $action->get_settings(), $formData['extra']['_form_id'], $submission);
                                $email->process((array) $action_settings, $formData['extra']['_form_id'], (array) $submission->get_field_values());
                                
                            }
                        }

has anyone any idea how we can achieve this?

thanks in advance for any help!

0

There are 0 best solutions below