Last active
May 6, 2025 08:34
-
-
Save wpmudev-sls/df88ed6d23f5d9c52b86eb1f90ca45f7 to your computer and use it in GitHub Desktop.
[Forminator Pro] - Add phone field's dial code to HTML summary
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Plugin Name: [Forminator Pro] Dial code on summary | |
* Description: Add phone field's dial code on HTML summary. | |
* Author: Prashant @ WPMUDEV | |
* Task: SLS-7019 | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { | |
exit; // Exit if accessed directly. | |
} | |
add_action( | |
'wp_footer', | |
function () { | |
global $post; | |
if ( is_a( $post, 'WP_Post' ) && ! has_shortcode( $post->post_content, 'forminator_form' ) ) { | |
return; | |
} | |
?> | |
<script type="text/javascript"> | |
jQuery(document).ready(function($){ | |
setTimeout(function() { | |
$('.forminator-custom-form').trigger('after.load.forminator'); | |
},500); | |
$(document).on('after.load.forminator', function(e, form_id) { | |
if ( 'forminator-module-48334' === e.target.id ) { // Please change 48334 to your form's ID. | |
var phone_val = ''; | |
var dial_code = ''; | |
$('#phone-1 input').on('change', function(){ | |
phone_val = $(this).val(); | |
dial_code = $(this).parent().find('.iti__selected-dial-code').text(); | |
}); | |
$(document).on('forminator.front.pagination.move', function() { | |
setTimeout(function(){ | |
if ( phone_val ) { | |
$('#html-2 .forminator-merge-tags').html($('#html-2 .forminator-merge-tags').html().replace(dial_code, '')); | |
$('#html-2 .forminator-merge-tags').html($('#html-2 .forminator-merge-tags').html().replace(phone_val,dial_code + ' ' + phone_val)); | |
} | |
},500); | |
}); | |
$(document).on('change', '#consent-1 input', function() { | |
setTimeout(function() { | |
if ( phone_val ) { | |
$('#html-2 .forminator-merge-tags').html($('#html-2 .forminator-merge-tags').html().replace(dial_code, '')); | |
$('#html-2 .forminator-merge-tags').html($('#html-2 .forminator-merge-tags').html().replace(phone_val,dial_code + ' ' + phone_val)); | |
} | |
},500); | |
}); | |
} | |
}); | |
}); | |
</script> | |
<?php | |
}, | |
9999 | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment