Last active
March 5, 2020 10:36
-
-
Save wpmudev-sls/619d8140953daac80094abadad0ef66f to your computer and use it in GitHub Desktop.
[Forminator] - Add entry id to redirect url
This file contains 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] - Add entry id to redirect url | |
* Description: [Forminator] - Add entry id to redirect url | |
* Author: Thobk @ WPMUDEV | |
* Author URI: https://premium.wpmudev.org | |
* License: GPLv2 or later | |
*/ | |
if ( ! defined( 'ABSPATH' ) ) { exit; } elseif ( defined( 'WP_CLI' ) && WP_CLI ) { return; } | |
add_action( 'plugins_loaded', 'wpmudev_forminator_add_entry_id_to_redirect_url_func', 100 ); | |
function wpmudev_forminator_add_entry_id_to_redirect_url_func() { | |
if ( defined('FORMINATOR_PRO') && class_exists( 'Forminator' ) ) { | |
class WPMUDEV_Forminator_Add_Entry_ID_To_Redirect_URL{ | |
private $form_id = 2812;//enter form_id here | |
private $redirect_url = 'http://wp.local/inc/account/';//enter your redirect url here, it must be matches with the link you added on the form | |
private $entry_id; | |
public function __construct(){ | |
add_action( 'forminator_custom_form_submit_before_set_fields', array( $this, 'retrive_entry_id' ), 10, 2 ); | |
add_filter( 'forminator_replace_form_data', array( $this, 'add_entry_id_to_redirect_url') ); | |
} | |
public function retrive_entry_id( $entry, $form_id ){ | |
if( $this->form_id == $form_id ){ | |
$this->entry_id = $entry->entry_id; | |
} | |
} | |
public function add_entry_id_to_redirect_url( $content ){ | |
if( $this->entry_id && $this->redirect_url === $content ){ | |
$content = add_query_arg('entry_id', $this->entry_id, $content); | |
} | |
return $content; | |
} | |
} | |
$run = new WPMUDEV_Forminator_Add_Entry_ID_To_Redirect_URL; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment