Redirect WordPress Page

How to Create Custom Registration URL in WordPress without Plugin

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:

  1. Change the page slug ‘register’ (green colored text in the code). This is the page you want to redirect from.
  2. 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 example home_url('/mypage')

Check this article too: How to Redirect Successful Registration to Thank You Page in WordPress

Spread the love

A teacher by profession, a traveler by passion and a netizen by choice.

Morshed Alam

You use WordPress! Why don't we share our experiences. It may be a tutorial, tips, tricks, tweaks or about security, performance or WordPress news. Write Today

Leave a Comment

Your email address will not be published. Required fields are marked *