Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save patrickfreitasdev/f69213226ef5d0c1b1d70a8a9a2ed4ab to your computer and use it in GitHub Desktop.

Select an option

Save patrickfreitasdev/f69213226ef5d0c1b1d70a8a9a2ed4ab to your computer and use it in GitHub Desktop.
<?php
if ( ! defined( 'ABSPATH' ) ) { exit; } elseif ( defined( 'WP_CLI' ) && WP_CLI ) { return; }
add_action( 'plugins_loaded', 'wpmudev_forminator_fix_redirect_blank_space', 100 );
function wpmudev_forminator_fix_redirect_blank_space() {
if ( class_exists( 'Forminator' ) ) {
class WPMUDEV_FIX_redirect_blank_space{
private $form_id = 41393; //enter form_id here
private $can_redirect = false;
public function __construct(){
add_action( 'forminator_custom_form_submit_before_set_fields', array( $this, 'form_id_checker' ), 10, 2 );
add_filter( 'forminator_replace_form_data', array( $this, 'redirect_fix'), 20, 1 );
}
public function form_id_checker( $entry, $form_id ){
if( $this->form_id == $form_id ){
$this->can_redirect = true;
}
}
public function redirect_fix( $content ){
if( $this->can_redirect ){
$content = str_replace( ' ', '', $content );
}
return $content;
}
}
$run = new WPMUDEV_FIX_redirect_blank_space;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment