Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions classes/controllers/FrmFormsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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 ) {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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_';
Expand Down Expand Up @@ -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 );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function apply_filters invoked with 4 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.


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'] );
Expand Down
11 changes: 11 additions & 0 deletions classes/views/frm-form-actions/on_submit_settings.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function apply_filters invoked with 4 parameters, 2 required


The function call is not valid, which will result in a fatal runtime error.


$col_count = count( $types );

if ( $col_count <= 4 ) {
Expand Down