0

http://www.mywebsite.com/my-page

on my wordpress page i have a form and i am redirecting my wordpress page to some other website after form submit

i have following code in my functions.php file for submitting form.

add_action('init', 'redirect');
function redirect(){
if(isset($_post['submit']))
{
    wp_redirect("www.google.com",301); exit();

}
}

but its not redirecting and showing 404 error and following url on submit http://www.mywebsite.com/my-post/www.google.com

here i am using shortcode to display form on my wordpress page.

what is the reason? any clue?

5
  • Lowercase $_post might be your problem. Try $_POST instead. If that doesn't work, I'll work up an answer for you using a different route. Commented Mar 4, 2012 at 21:30
  • i am using $_POST in functions.php file. here i just wrote in hurry.
    – naeplus
    Commented Mar 4, 2012 at 21:30
  • this is not the issue. i try this also. please try different route.
    – naeplus
    Commented Mar 4, 2012 at 21:31
  • What about http:// in front of your URL? Commented Mar 4, 2012 at 21:34
  • Great.. Its just started working. thank you so much. please post answer bellow. so you can take credit.
    – naeplus
    Commented Mar 4, 2012 at 21:42

1 Answer 1

1

You need to place http:// in front of the URL for wp_redirect to work properly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.