There is a post already asking the question here, but it’s from 2024 and was never answered.
The short story is that I have a newsletter signup form that uses a custom action to make sure the user doesn’t already exist, and isn’t already in the “newsletter” role before making the account and/or assigning the role.
If a user is made or added, a welcome email is added using the “email” action. If a user is already signed up, an error is returned to the form using:
else {
$result_output = "This address was already subscribed. Please search your inbox for the original welcome email.";
$result_type = 'error';
}
}
$form->set_result([
'action' => 'my_custom_action',
'type' => "$result_type", // 'success', 'error', or 'info'
'message' => "$result_output",
]);
But… the welcome email still sends. How do I communicate to the form that the custom action has failed and I want no further actions triggered?