You need a filter not an action. Something like this (notes are commented into the code. You have a few PHP errors that you need to correct):
function signup_validate_insert($post){
$errors = false;
if (isset($post['submit_msg'])) {
// validate , insert into database
}
return $errors;
}
add_filter('signup_insert', 'signup_validate_insert');
$errors = apply_filters('signup_insert', $_POST);
if((!empty($errors))){ // $errors is going to be set; use empty() ?>
<div class="errors"><?php
foreach($errors as $error) { ?>
<p class="errortext"><?php
echo $error; // echo was missing; you would have no output ?>
</p><?php
} ?>
</div><?php
}
Filters return content. Actions do stuff. I you want an action echo
directly from your callback:
function signup_validate_insert($post){
$errors = false;
if (isset($post['submit_msg'])) {
// validate , insert into database
}
if((!empty($errors))){ // $errors is going to be set; use empty() ?>
<div class="errors"><?php
foreach($errors as $error) { ?>
<p class="errortext"><?php
echo $error; // echo was missing; you would have no output ?>
</p><?php
} ?>
</div><?php
}
}
add_action('signup_insert', 'signup_validate_insert');
do_action('signup_insert', $_POST);
Honestly, what you are doing may be overly complicated and the whole thing might best be written without the hook at all. Do you need this to be extensible by a third party?
Try looking over:
Clarification on filters and hooks
Difference Between Filter and Action Hooks?