Click to initialize TinyMCE
In this guide we’ll learn how pass actions output across multiple actions, allowing to chain actions and their result.
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.
Add actions on form submission
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;
}
There are various tags you can use to retrieve the previous Post/Term/User Action Post Title, Admin URL, Author Name etc… See Cheatsheet.