Skip to main content

How do I redirect using "xyz snippet" in a wordpress site

I am using xyz-snippet to insert some php code (post forms and handling post requests) in some Wordpress pages. In the work I am doing it is necessary to take input from a user (with a post form) and process it and redirect them to another page depending on their input. I tried the header() function and it didn't work now I am trying this:

if (empty($entry)){
        echo('<h1>I am empty and should be redirecting now</h1>');
        $url = 'https://jimmyshapopi.com';
        wp_redirect($url);
        exit;}

This is not working. I know my logic is fine because that <h1> tag actually prints but the redirect is not working.

XYZ PHP Snippet, uses shortcodes for you to enter you php code into a page. What am I missing?



source https://stackoverflow.com/questions/68957581/how-do-i-redirect-using-xyz-snippet-in-a-wordpress-site

Comments