First, your code attempts to use $_POST['nom']
whether the value is set or not. You are generating non-fatal “Undefined index” warning every time that runs. Clean that up and use !empty($_POST['nom'])
instead of $_POST['nom']!=NULL
.
With template_redirect
you’d want to redirect to an existing page, something like the following from another answer:
function redirect_cat_wpse_207298() {
if (is_category()) {
global $post;
wp_safe_redirect(get_permalink($post->ID));
die;
}
}
add_action('template_redirect','redirect_cat_wpse_207298');
Since you say “create a page”, I am guessing there is no page to redirect to, so you probably want template_include
instead. Something like:
function recherche_multi_critere() {
if(!empty($_POST['nom'])) {
get_header();
var_dump($_POST['nom']);
get_footer();
}
}
add_action('template_include', 'recherche_multi_critere');