0

I'm using word-press and have embedded the following code in the body of the website with hope it will redirect the user the relevant page.

$current_user = wp_get_current_user();
$e=$current_user->user_email;

$result = mysql_query("SELECT users.user_email
FROM users
WHERE users.user_email='$e'");

$numResult = mysql_num_rows($result);
if ($numResult > 0) {
header( "Location: ../Confirm" );
} else {
header( "Location: ../Insert" );
}

Unfortunately no redirect happens...any ideas?

itguyme
  • 43
  • 2
  • 11

1 Answers1

0

WordPress has its own function to redirect: wp_redirect()

Just make sure your code executes before anything else. A good spot is the header.php file inside the theme, before the tag.

https://developer.wordpress.org/reference/functions/wp_redirect/

alesub
  • 1,402
  • 13
  • 14