Overview

In this guide we’ll learn how to set multiple actions in a form and retrieve an action output to use it a latter action.

Action Configuration

This form will create a new post, send an e-mail with the newly created post title and redirect the user to the post permalink. To do so, the Email Action use the {action:post:post_title}Template Tag as subject, and the Redirect Action use the {action:post:permalink} Template Tag as the redirection URL.

Note that form actions are executed in the order defined the in Form UI, which means the Email and Redirect Actions have to be set after the Post Action.

Dynamic Form

Add actions on form submission

Click the "Add action" button below to start creating your layout
0 Custom action

Set a unique action slug.

0 Email action
0 Option action

Fill inputs with values

0 Post action
Click to initialize TinyMCE

Fill inputs with values

0 Redirect action
0 Term action
Click to initialize TinyMCE

Fill inputs with values

0 User action
Click to initialize TinyMCE

Fill inputs with values

1 Post action
Click to initialize TinyMCE

Fill inputs with values

2 Email action
3 Redirect action

Actions Ouput Data in a Hook

It is also possible to retrieve the previous action output in any hook using the acfe_form_get_action() helper (See documentation). Here is a usage example to use the previous Post Action permalink and set it as a redirect Url using a hook:

add_filter('acfe/form/submit/redirect_url/form=my-form', 'my_form_redirect_url', 10, 3);
function my_form_redirect_url($url, $form, $action){
    
    // get previous post action permalink
    $post_permalink = acfe_form_get_action('post', 'permalink');
    
    // make sure the permalink exists
    if(!empty($post_permalink)){

        // redirect to url
        return $post_permalink;
        
    }
    
    // else do not redirect
    return false;
    
}

Others Output Data

There are various tags you can use to retrieve the previous Post/Term/User Action Post Title, Admin URL, Author Name etc… See Cheatsheet.