Hi @satrya
I hope you’re well today!
Currently it isn’t possible out of the box but should be doable with a bit of additional custom code. This is example (not very elegant but working so you can use it) code:
<?php
add_action( 'wp_footer', 'wpmu_forminator_radio_redirect', 99 );
function wpmu_forminator_radio_redirect() {
?>
<script>
jQuery(document).ready(function($) {
$(document).on('after.load.forminator', function(e, form_id) {
var next_button = document.querySelector('.forminator-button-next'),
click_event = new CustomEvent('change_evt'),
clickable_elements = document.querySelectorAll('.radio-redirect .forminator-radio input[value="one"]'),
redirect_elements = document.querySelectorAll('.radio-redirect .forminator-radio input[value="two"]'),
radios = document.querySelectorAll('.radio-redirect input[type="radio"]');
clickable_elements.forEach(
clickable_element => {
clickable_element.addEventListener('click', wpmudev_clickables_event_callback)
}
)
redirect_elements.forEach(
redirect_element => {
redirect_element.addEventListener('click', wpmudev_redirects_event_callback)
}
)
function wpmudev_clickables_event_callback() {
clickable_elements.forEach(radio => {
radio.addEventListener('change', wpmudev_change_evt_callback)
})
}
function wpmudev_redirects_event_callback() {
redirect_elements.forEach(radio => {
radio.addEventListener('change', wpmudev_change_evt_redir_callback)
})
}
function wpmudev_change_evt_callback(e) {
if (e.currentTarget.checked) {
$('.forminator-button-next').trigger('click');
}
}
function wpmudev_change_evt_redir_callback(e) {
if (e.currentTarget.checked) {
window.location.replace("https://google.com");
}
}
});
setTimeout(function() {
$('.forminator-custom-form').trigger('after.load.forminator');
}, 100);
});
</script>
<?php
}
Assuming you only have two options there it should work. To use it on site first you need to add it as MU plugin:
– create an empty file with a .php extension (e.g. “formiantor-radio-redirects.php”)
– copy and paste code into it
– save the code and upload it to the “/wp-content/mu-plugins” folder of your site’s WordPress install.
Second, you need to add this string to the “Additional CSS Classes” option in “Styling” settings of your radio button on form; note no dot prefix here:
radio-redirect
Finally, you need to make some small changes in the code:
1. in these two lines
clickable_elements = document.querySelectorAll('.radio-redirect .forminator-radio input[value="one"]'),
redirect_elements = document.querySelectorAll('.radio-redirect .forminator-radio input[value="two"]'),
replace words one and two with actual values of your radio button options; the first one is the one that should cause “next page” and the second is the one to redirect to URL.
2.in this line
window.location.replace("https://google.com");
replace URL with the one you want to redirect to.
I’ve tested it and it works fine on my end. Just note: the redirect will not cause the form to be submitted – it will just redirect to given URL. If you need form to be submitted and redirected instead, that would take more custom code and I’m afraid it’s a bit out of scope of our support.
Kind regards,
Adam