FR_SUBMITFORM
Class FR_SUBMITFORM
Source Source
File: src/integrations/forminator/triggers/fr-submitform.php
class FR_SUBMITFORM { /** * Integration code * @var string */ public static $integration = 'FR'; private $trigger_code; private $trigger_meta; /** * Set up Automator trigger constructor. */ public function __construct() { $this->trigger_code = 'FRSUBMITFORM'; $this->trigger_meta = 'FRFORM'; $this->define_trigger(); } /** * Define and register the trigger by pushing it into the Automator object */ public function define_trigger() { $trigger = array( 'author' => Automator()->get_author_name(), 'support_link' => Automator()->get_author_support_link( $this->trigger_code, 'integration/forminator/' ), 'integration' => self::$integration, 'code' => $this->trigger_code, /* translators: Logged-in trigger - Forminator */ 'sentence' => sprintf( esc_attr__( 'A user submits {{a form:%1$s}}', 'uncanny-automator' ), $this->trigger_meta ), /* translators: Logged-in trigger - Forminator */ 'select_option_name' => esc_attr__( 'A user submits {{a form}}', 'uncanny-automator' ), 'action' => 'forminator_custom_form_after_save_entry', 'priority' => 100, 'accepted_args' => 3, 'validation_function' => array( $this, 'fr_submit_form' ), 'options' => [ Automator()->helpers->recipe->forminator->options->all_forminator_forms( null, $this->trigger_meta ), ], ); Automator()->register->trigger( $trigger ); return; } /** * Validation function when the trigger action is hit * * @param int $form_id submitted form id. * @param array $response response array. * @param $method */ public function fr_submit_form( $form_id, $response, $method ) { if ( true === $response['success'] ) { $user_id = get_current_user_id(); if ( empty( $user_id ) ) { return; } $args = [ 'code' => $this->trigger_code, 'meta' => $this->trigger_meta, 'post_id' => intval( $form_id ), 'user_id' => intval( $user_id ), ]; $args = Automator()->maybe_add_trigger_entry( $args, false ); //Adding an action to save contact form submission in trigger meta $recipes = Automator()->get->recipes_from_trigger_code( $this->trigger_code ); do_action( 'automator_save_forminator_form_entry', $form_id, $recipes, $args ); if ( $args ) { foreach ( $args as $result ) { if ( true === $result['result'] ) { Automator()->maybe_trigger_complete( $result['args'] ); } } } } } }
Expand full source code Collapse full source code View on Github
Methods Methods
- __construct — Set up Automator trigger constructor.
- define_trigger — Define and register the trigger by pushing it into the Automator object
- fr_submit_form — Validation function when the trigger action is hit
- load_options