Hyper links not working

Hyperlink added in the Thank you message not working once the form is submitted, the links are appearing as text. Looking to add a PDF link once the user has submitted the form.

At the moment, the Redirect user to URL option in the Form Settings, redirects to a new page in the same tab, any quick workaround to redirect in a new tab, would be helpful.

  • Nithin

    Hello donnie,##1

    Hyperlink added in the Thank you message not working once the form is submitted, the links are appearing as text.

    I was able to replicate this in my local server too. I'm marking this as a bug, and bringing int the developers attention, so that a quick fix would be made available regarding this asap.

    the Redirect user to URL option in the Form Settings, redirects to a new page in the same tab, any quick workaround to redirect in a new tab, would be helpful.

    I'm checking this with the developer to see whether there is any quick way to make this work, will keep you posted once I get an update from the developer regarding this.

    Kind Regards,
    Nithin

  • Panos

    Hi there donnie ,

    the Redirect user to URL option in the Form Settings, redirects to a new page in the same tab, any quick workaround to redirect in a new tab, would be helpful.

    I'm afraid that opening new tabs/windows is not allowed from browsers as they tend to block pop ups which are opened from un-trusted events. So if this is added then the user will have to notice the blocker message and unblock, so it's not a suggested method.

    If you would like to confirm on your own that it will block the pop up, you could try adding the following snipped in a mu-plugin:

    add_filter( 'forminator_render_form_markup', function( $html, $form_fields, $form_type, $form_settings, $form_design ) {
    
    	ob_start();
    	?>
    	<script type="text/javascript">
    		(function($){
    			$(document).ready(function(){
    
    				$( document ).ajaxComplete(function( event, xhr, settings ) {
    
    					var url = 'https://target-site.com',
    						new_tab = window.open( url, '_blank' );
    
    					if ( ! new_tab ) {
    						//console.log( 'Can not open' );
    					}
    					else {
    						new_tab.focus();
    					}
    
    				});
    
    			});
    		})(jQuery);
    	</script>
    
    	<?php
    	$html .= ob_get_clean();
    
    	return $html;
    }, 20, 5 );

    Cheers!

  • Panos

    There might be another approach if you are interested, which might work but it requires custom work for validating the form fields. I wouldn't really recommend it, just providing it as an option. Here is the snippet:

    add_filter( 'forminator_render_form_markup', function( $html, $form_fields, $form_type, $form_settings, $form_design ) {
    
    	$page_id = 33502;
    	$page_link = get_page_link( $page_id );
    
    	ob_start();
    	?>
    	<script type="text/javascript">
    		(function($){
    			$(document).ready(function(){
    
    				var newTab,
    					form_id = 33501,
    					page_link = '<?php echo $page_link; ?>';
    
    				$(document).on('click','form.forminator-custom-form-'+ form_id +' .forminator-button', function() {
    
    					let validate = true,
    						email = $( '.forminator-email--field' ).val();
    
    					if( '' == $( '.forminator-name--field' ).val() ){
    						validate = false;
    					}
    
    					if( '' == email ){
    						validate = false;
    					}
    					else{
    						let emailFilter = /^([a-zA-Z0-9_.-])+@(([a-zA-Z0-9-])+.)+([a-zA-Z0-9]{2,4})+$/;
    						if ( ! emailFilter.test(email) ) {
    					        validate = false;
    					    }
    					}					
    
    					if( validate ){
    						newTab = window.open("about:blank", "newTab");
    					}
    
    					$( 'form.forminator-custom-form-' + form_id ).submit();
    
    				});
    
    				$( document ).ajaxComplete(function( event, xhr, settings ) {
    
    					if( xhr.responseJSON.success ){
    						window.open( page_link, "newTab" );
    					}
    					else{
    						newTab.close();
    					}
    
    				});
    
    			});
    		})(jQuery);
    	</script>
    
    	<?php
    	$html .= ob_get_clean();
    
    	return $html;
    }, 9999, 5 );

    The above validates the name and email fields on button click ( before submitting form ). If there is no validation error, the click event (which is trusted by browser) will open a new window. After form has been submited and ajax has replied with success, it will add the correct url to that new tab.

    In order to test the snippet, you need to replace the $page_id = 33502; with your own page id and form_id = 33501, with your form's id.

    Hope this helps!
    Cheers!

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.