diff --git a/classes/controllers/FrmFormsController.php b/classes/controllers/FrmFormsController.php index dbd4e3c371..ce07edebf7 100644 --- a/classes/controllers/FrmFormsController.php +++ b/classes/controllers/FrmFormsController.php @@ -3075,6 +3075,7 @@ public static function trigger_redirect( $form, $params, $args ) { * * @since 2.05 * @since 6.0 `$args['force_delay_redirect']` is added. + * @since x.x `$args['on_submit_action']` is added. * * @param array $args { * The args. @@ -3085,6 +3086,7 @@ public static function trigger_redirect( $form, $params, $args ) { * @type string $action The action event. Accepts `create` or `update`. * @type array $fields The array of fields. * @type int $force_delay_redirect Force to show the message before redirecting in case redirect method runs. + * @type object $on_submit_action The Confirmation action being run, when there is one. * } */ public static function run_success_action( $args ) { @@ -3248,7 +3250,8 @@ public static function run_on_submit_actions( $args ) { FrmOnSubmitHelper::populate_on_submit_data( $args['form']->options ); self::run_success_action( $args ); } elseif ( 1 === count( $args['conf_method'] ) ) { - FrmOnSubmitHelper::populate_on_submit_data( $args['form']->options, reset( $args['conf_method'] ) ); + $args['on_submit_action'] = reset( $args['conf_method'] ); + FrmOnSubmitHelper::populate_on_submit_data( $args['form']->options, $args['on_submit_action'] ); $args['conf_method'] = $args['form']->options['success_action']; self::run_success_action( $args ); } else { @@ -3313,6 +3316,7 @@ public static function run_single_on_submit_action( $args, $action ) { private static function get_run_success_action_args( $args, $action ) { $new_args = $args; + $new_args['on_submit_action'] = $action; FrmOnSubmitHelper::populate_on_submit_data( $new_args['form']->options, $action, $args['action'] ); $opt = 'update' === $args['action'] ? 'edit_' : 'success_'; @@ -3343,7 +3347,24 @@ private static function load_page_after_submit( $args ) { // phpcs:ignore Universal.Operators.StrictComparisons if ( ! $post || $args['form']->options[ $opt . '_page_id' ] != $post->ID ) { - $page = get_post( $args['form']->options[ $opt . '_page_id' ] ); + $page = get_post( $args['form']->options[ $opt . '_page_id' ] ); + + /** + * Allows replacing the output of a Confirmation action that shows page content. + * + * @since x.x + * + * @param string|null $output Return a string to show it instead of the page content. + * @param WP_Post $page The selected post. + * @param array $args See {@see FrmFormsController::run_success_action()}. + */ + $output = apply_filters( 'frm_on_submit_page_output', null, $page, $args ); + + if ( is_string( $output ) ) { + echo $output; // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped + return; + } + $old_post = $post; $post = $page; $content = apply_filters( 'frm_content', $page->post_content, $args['form'], $args['entry_id'] ); diff --git a/classes/views/frm-form-actions/on_submit_settings.php b/classes/views/frm-form-actions/on_submit_settings.php index 255c89f8da..1a6ca2708f 100644 --- a/classes/views/frm-form-actions/on_submit_settings.php +++ b/classes/views/frm-form-actions/on_submit_settings.php @@ -35,6 +35,17 @@ ), ); +/** + * Filters the Confirmation action types and the settings shown for each. + * + * @since x.x + * + * @param array $types Action types keyed by type, each with `label`, `icon` and `sub_settings`. + * @param object $instance Form action post object. + * @param array $args Contains `form`, `action_key`, `values`. + */ +$types = apply_filters( 'frm_on_submit_types', $types, $instance, $args ); + $col_count = count( $types ); if ( $col_count <= 4 ) {