Forum Replies Created

Viewing 1 replies (of 1 total)
  • I’d like to move from a form submission to another page based on the post category, but can’t seem to get this to work within the funcitons.php page. I have multiple pages using the same contact form, and each is tagged with a category. Based on which page they submit the form from, I want to redirect them to a category-specific “next” page. Here’s the code I have – any suggestions would be appreciated!

    add_action('wpcf7_mail_sent', 'ip_wpcf7_mail_sent');
    function ip_wpcf7_mail_sent($wpcf7)
    {
    	$on_sent_ok = $wpcf7->additional_setting('ip_on_sent_ok', false);
    
    	global $wp_query;
    	$post = $wp_query->post;
    	$category = get_the_category($post->ID);
    	$thisCatName = $category[0]->category_nicename;
    	$redirectPage = "next-" . $thisCatName . ".html";
    
    	if (is_array($on_sent_ok) && count($on_sent_ok) > 0)
    	{
    		wp_redirect(trim($redirectPage));
    		exit;
    	}
    }
Viewing 1 replies (of 1 total)