I’m working on a project where we created a custom registration form with Gravity Forms with a custom user role assigned when they registered.
As a result, I needed a way to redirect all users who might happen to stumble across the default WordPress registration page / url and redirect them to my new Registration page at http://sitename.com/register
If your registration url is also /register, the snippet below is plug and play! Just create your registration page, add a registration form and keep on rolling!
I hope you have a great day!
| <?php | |
| add_filter('register','hjs_register_url'); | |
| function hjs_register_url($link){ | |
| /* Change wp registration url */ | |
| return str_replace(site_url('wp-login.php?action=register', 'login'),site_url('register', 'login'),$link); | |
| } | |
| add_filter('site_url', 'hjs_fix_register_urls', 10, 3); | |
| function hjs_fix_register_urls($url, $path, $orig_scheme){ | |
| /* | |
| Site URL hack to overwrite register url | |
| http://en.bainternet.info/2012/wordpress-easy-login-url-with-no-htaccess | |
| */ | |
| if ($orig_scheme !== 'login') | |
| return $url; | |
| if ($path == 'wp-login.php?action=register') | |
| return site_url('register', 'login'); | |
| return $url; | |
| } |


