Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

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?

share|improve this question
    
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. –  Brian Fegter Mar 4 '12 at 21:30
    
i am using $_POST in functions.php file. here i just wrote in hurry. –  Naeem Mar 4 '12 at 21:30
    
this is not the issue. i try this also. please try different route. –  Naeem Mar 4 '12 at 21:31
    
What about http:// in front of your URL? –  Brian Fegter Mar 4 '12 at 21:34
    
Great.. Its just started working. thank you so much. please post answer bellow. so you can take credit. –  Naeem Mar 4 '12 at 21:42

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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