Hello @lknights1987 ,
Can you try this snippet as MU plugin https://premium.wpmudev.org/docs/getting-started/download-wpmu-dev-plugins-themes/#installing-mu-plugins
add_action( 'forminator_before_form_render', 'wpmudev_field_addition_phone', 10, 5 );
function wpmudev_field_addition_phone( $id, $form_type, $post_id, $form_fields, $form_settings ) {
$phone_fields = Forminator_API::get_form_fields_by_type( $id, 'phone' );
if ( !is_wp_error( $phone_fields ) ) {
return;
}
$data = array(
'condition_action' => 'show',
'condition_rule' => 'all',
'placeholder' => 'E.g. +1 300 400 5000',
'conditions' => array
(
),
'type' => 'phone',
'options' => array
(
),
'cols' => '12',
'required' => true,
'validation' => 'none',
'field_label' => 'Phone Number',
'description' => '',
'validation_text' => '',
'custom-class' => ''
);
$type = 'phone';
$wrapper = uniqid( 'wrapper-' );
$field_id = $type . '-1';
// Create empty field.
$field = new Forminator_Form_Field_Model();
// Update field settings.
$data['id'] = $field_id;
$data['element_id'] = $field_id;
$data['type'] = $type;
$data['form_id'] = $wrapper;
// Bind settings to the fieldget_form_wrapper.
$field->import( $data );
// Update field slug.
$field->slug = $field_id;
// Load form model.
$model = Forminator_Base_Form_Model::get_model( $id );
// Add the field to form.
$model->add_field( $field );
// Update all fields cols in the wrapper.
$model->update_fields_by_wrapper( $wrapper );
// Save the form.
$model->save();
?>
<script type="text/javascript">window.location.href = window.location.href;</script>
<?php
}
This snippet will add phone-1 field to all the forms as soon as they are loaded on front end.
kind regards,
Kasia