I have a function which checks if $_POST is set (a form which submits to the same page). I need to have it initialized before the page is loaded because the function will do a header redirect if the validation goes through without errors.
So the function is registered like this:
add_action('init', 'signup_validate_insert');
And the function itself starts like this:
function signup_validate_insert(){
$errors = false;
if (!empty($_POST['submit_msg'])) {
//validation and stuff
}
And if there are errors, it returns the errors array:
return $errors;
When the submit button is pressed, the function registers it as it should, and goes through the validation. I have checked to see that the errors array is being filled in the function. But the variable is not returned! (although I have set "return $errors")
The variable is supposed to be returned to the template, where the errors can be displayed if $errors are not empty.
I have tried switching to add_filter
instead, with the same result.
So the question is really how to be able to return this variable - hope you can help!
add_action()
, it will always returntrue
.