Workflow Actions (Post-Submit)
After a form is successfully submitted, OForms can run one or more workflow actions.
Available Actions
Subscribe to OMailer list
php[
'type' => 'om_subscribe',
'list_id' => 3,
'email_field' => 'email', // form field name
'first_name_field' => 'first_name', // optional
'last_name_field' => 'last_name', // optional
'tag' => 'from-contact-form', // optional tag slug
]
Create WordPress user
php[
'type' => 'create_user',
'email_field' => 'email',
'username_field' => 'username',
'password_field' => 'password',
'role' => 'subscriber',
'auto_login' => true,
]
Assign role to logged-in user
php[
'type' => 'assign_role',
'role' => 'editor',
]
Fire webhook
php[
'type' => 'webhook',
'url' => 'https://hooks.zapier.com/...',
'method' => 'POST',
'secret' => 'optional_hmac_secret',
]
Redirect
php[
'type' => 'redirect',
'url' => 'https://yoursite.com/thank-you',
'query_args' => [ 'entry_id' => '{{entry_id}}' ],
]
Adding Custom Actions
phpadd_filter( 'of_workflow_actions', function( array $actions ): array {
$actions['my_action'] = [
'label' => 'My Custom Action',
'handler' => 'my_action_handler',
];
return $actions;
});
function my_action_handler( array $config, int $entry_id, int $form_id ): void {
$values = OForms\Entries\Entry::get( $entry_id )->get_values();
// do something
}