Hey Guys,
Though id share this enrollment plugin I wrote for mail in a box api using elementor forms…
Simply replace the details below zip it and install plugin…
Replace [‘User’] [‘Domain’] [‘Password’] in the lines below with the correct label for your particular form… You may adjust these lines according to your form I allow users to choose from various domains in a drop down
$fUser = $form_data[‘User’]."@".strtolower($form_data[‘Domain’] );
$fPass = $form_data[‘Password’] ;
Next replace Box Admin User and Box Admin Pass with admin credentials for your box
$username = “Box Admin User”;
$password = “Box Admin Pass”;
and finally replace box.example.com on this line with your box address
$response = wp_remote_post( ‘https://box.example.com/admin/mail/users/add’,
Enjoy!
> <?php
> /**
> * Plugin Name: Elementor Forms Mail In A Box Enrollment
> * Plugin URI: https://adeptgroup.llc
> * Description: Adds a second Webhook to the form
> * Version: 1.0.0
> * Author: Giuseppe Portaluppi
> * Author URI: https://adeptgroup.llc
> * License: GPLv2 or later
> * License URI: http://www.gnu.org/licenses/gpl-2.0.html
> */
>
> class Elementor_Form_Additional_Webhook {
>
> function hooks(){
> //Add our additional webhook right here
> add_action( 'elementor_pro/forms/new_record', array( $this, 'manipulate_form_submission' ), 10, 2 );
> }
>
> function manipulate_form_submission( $record, $ajax_handler ) {
>
> $form_data = $record->get_formatted_data();
>
> $fUser = $form_data['User']."@".strtolower($form_data['Domain'] );
> $fPass = $form_data['Password'] ;
> $body = array('email' => $fUser, 'password' => $fPass);
>
> $username = "Box Admin User";
> $password = "Box Admin Pass";
> $auth = base64_encode($username . ':' . $password);
>
> $args = [
> 'headers' => [
> 'Authorization' => 'Basic '.$auth
> ],
> 'body' => $body
> ];
>
> $response = wp_remote_post( 'https://box.example.com/admin/mail/users/add',
> $args);
> $response_body = wp_remote_retrieve_body( $response );
> $ajax_handler->add_error_message( $response_body );
>
> //if the failure of our additional webhook should prevent the form from submitting...
> if( is_wp_error( $response ) ) {
> $msg = 'There was a problem launching the rocket. Please check with mission control.';
> $ajax_handler->add_error( $field['id'], $msg );
> $ajax_handler->add_error_message( $msg );
>
> $ajax_handler->is_success = false;
> }
> }
> }
> $elementor_webhook_239909870234 = new Elementor_Form_Additional_Webhook();
> $elementor_webhook_239909870234->hooks();