Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- add_action( 'plugins_loaded', 'wpmudev_forminator_add_redirect_url_to_hidden_field_func', 100 );
- function wpmudev_forminator_add_redirect_url_to_hidden_field_func() {
- if ( defined('FORMINATOR_PRO') && class_exists( 'Forminator' ) ) {
- class wpmudev_forminator_add_redirect_url_to_hidden_field_func{
- private $form_id = 6;//enter form_id here
- private $redirect_url;
- public function __construct() {
- add_filter( 'forminator_form_submit_response', array( $this, 'get_redirect_url_form_submission' ), 20, 2 );
- add_filter( 'forminator_form_ajax_submit_response', array( $this, 'get_redirect_url_form_submission'), 20, 2 );
- add_action( 'forminator_form_after_handle_submit', array( $this, 'add_redirect_url_to_hidden_field'), 10, 2);
- add_action( 'forminator_form_after_save_entry', array( $this, 'add_redirect_url_to_hidden_field'), 10, 2);
- }
- public function get_redirect_url_form_submission( $response, $form_id ) {
- if ( $this->form_id == $form_id ) {
- if ( ! empty( $response['url'] ) ) {
- $this->redirect_url = $response['url'];
- }
- }
- return $response;
- }
- public function add_redirect_url_to_hidden_field( $form_id, $response ) {
- if ( $this->form_id == $form_id ) {
- $entry_meta = array(
- array(
- 'name' => 'hidden-1',
- 'value' => $this->redirect_url
- )
- );
- $entries = Forminator_API::get_entries( $form_id );
- Forminator_API::update_form_entry( $form_id, $entries[0]->entry_id, $entry_meta );
- }
- }
- }
- $run = new wpmudev_forminator_add_redirect_url_to_hidden_field_func;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement