redirect does not work in ajax function

I’m using ajax to post the form data. In the end I want to redirect to homepage. I’m trying following code, it does not work. It returns error 302. How can I redirect in the following function? Thanks. add_action(‘wp_ajax_nopriv_custom_register’, ‘custom_register’); add_action(‘wp_ajax_custom_register’, ‘custom_register’); function custom_register(){ //process wp_redirect( home_url() ); exit; } 2 Answers 2 The AJAX … Read more

PHP – redirect https to http and www to non-www

**EDIT: I finally figured this out. Scroll down for my self-answered self-accepted answer (green check mark) ** I’m currently using functions.php to redirect https urls to http for a site which currently has no SSL certificate: function shapeSpace_check_https() { if ((!empty($_SERVER[‘HTTPS’]) && $_SERVER[‘HTTPS’] !== ‘off’) || $_SERVER[‘SERVER_PORT’] == 443) { return true; } return false; … Read more

Redirect on successful login

I am using the following snippet to control redirects after successful logins…. add_action( ‘wp_login’, ‘redirect_on_login’ ); // hook failed login function redirect_on_login() { $referrer = $_SERVER[‘HTTP_REFERER’]; $homepage = get_option(‘siteurl’); if (strstr($referrer, ‘incorrect’)) { wp_redirect( $homepage ); } elseif (strstr($referrer, ’empty’)) { wp_redirect( $homepage ); } else { wp_redirect( $referrer ); } } What i want … Read more

htaccess https redirect from www to non-www

I have added .htaccess https redirect from www to non-www with: <IfModule mod_rewrite.c> RewriteEngine on RewriteCond %{HTTP_HOST} ^www\. RewriteCond %{HTTPS}s ^on(s)|off RewriteCond http%1://%{HTTP_HOST} ^(https?://)(www\.)?(.+)$ RewriteRule ^ %1%3%{REQUEST_URI} [R=301,L] </IfModule>` When I visit my domain, the following redirects happen without any problem: http://www.example.com → http://example.com http://www.example.com/abc → http://example.com/abc But when I visit my domain as https://www.example.com … Read more

Login to wp-admin “redirect_to” points to wrong URL after migration

I have a WordPress site hosted on GoDaddy, it’s a Windows server, (i have the web.config set up). and .htaccess correctly configured. The site was working on example.com/wordpress , as it was a development test. I moved the site to example.com . I changed the site url and wordpress URL to example.com on the database … Read more

How to 301 private posts rather than 404?

How do I 301 redirect private pages, rather than 404 them? If a post is private, WordPress filters it out in the SQL query, so there are no $post variables to work with. I’d like for this code to work, but doesn’t: add_action(‘wp’,’redirect_stuffs’, 0); function redirect_stuffs(){ global $post; if ( $post->post_status == “private” && !is_admin() … Read more