To fight spam registration, this could be helpful. In this tutorial, we will use WordPress function wp_safe_redirect().
First, create a page. No need to add content. We will use this page’s slug. Suppose it’s “register”.
Paste following code in your theme’s functions.php
add_action('template_redirect', 'weusewp_custom_reg');
function weusewp_custom_reg() {
if( is_page('register')) {
wp_safe_redirect(wp_registration_url());
exit();
}
}
Now your registration URL will be yoursite.com/register
instead of yoursite.com/wp-login.php?action=register
== The End ==
Note: The title of this tutorial could be “How to Redirect a WordPress Page Without Plugins“. You can redirect any WordPress page by changing just two things in the above code:
- Change the page slug ‘register’ (green colored text in the code). This is the page you want to redirect from.
- Change the location wp_registration_url() (orange colored text in the code). This is the path or URL to redirect to. Use
home_url()
to redirect to the home page. You can use any URL, for examplehome_url('/mypage')
Check this article too: How to Redirect Successful Registration to Thank You Page in WordPress