33

There is

wp_login_url, wp_logout_url, but what what about registration url?

Is there standard way to get link to registration? I need to display a link to registration page with further redirect to previous page.

PS I am using my theme login.

1
  • Have updated the answer to match your original question ;)
    – johnhunter
    Commented Mar 4, 2011 at 10:04

9 Answers 9

55

The following will return the registration url:

<?php

    echo site_url('/wp-login.php?action=register');

?>

UPDATE:

To get the registration url with a redirect to the current page use:

<?php

    echo site_url('/wp-login.php?action=register&redirect_to=' . get_permalink());

?>
4
  • 1
    Don't forget to escape the redirect_to parameter: esc_url_raw(get_permalink())
    – Jason
    Commented Jun 17, 2013 at 14:47
  • Why do you need to escape get_permalink?
    – Jake
    Commented Jan 12, 2014 at 20:35
  • Oh Wordpress! So elegant... Thanks for the reply John. Commented Jul 16, 2014 at 7:55
  • just what I was looking for to test registration from the browser
    – Madivad
    Commented Aug 31, 2017 at 0:17
20

Since 3.6, there is now a func: http://codex.wordpress.org/Function_Reference/wp_registration_url

<?php echo wp_registration_url(); ?>

You can override it with the register_url filter.

add_filter( 'register_url', 'custom_register_url' );
function custom_register_url( $register_url )
{
    $register_url = get_permalink( $register_page_id );
    return $register_url;
}
6

I know this is an old question, but for anyone picking it up use wp_register().

It automatically determines if you're logged in and supplies either a link to the admin section of the site, or a link to the register form.

It also respects the settings in Settings -> General -> Membership (Anyone Can Register?)

2

If I understand correctly you are asking for default Word Press registration page. That would be www.domainname.com/wp-signup.php

2
<?php echo wp_registration_url(); ?> 

https://codex.wordpress.org/Function_Reference/wp_registration_url

1

2 points here

  1. Make sure you have turn on the "Anyone can register" in the setting page
  2. if you host in a subfolder, make sure you include

Without subfolder:

<a href="/wp-login.php?action=register">Register</a>

OR

<a href="<?php echo wp_registration_url(); ?>">Register</a>

With subfolder

<a href="shop/wp-login.php?action=register">Register</a>
0

In case of hosting your wordpress site in a subfolder (e.g.: mysite.com/myblog) you also need to include your site's url as follows:

<?php echo get_site_url() . "/wp-login.php?action=register" ?>

--> http://mysite.com/myblog/wp-login.php?action=register

Otherwise you will be redirected to a non-existing page

--> http://mysite.com/wp-login.php?action=register

0

1st of all I'm a WP newbe.

wp_registration_url can redirect the new user back to the page he came from, buy without enforcing login on the way (I dont use auto login because i want the user to authenticate the mail).

i use instead (sample with Allow PHP in posts plugin):

<a href="[php]echo site_url('/wp-login.php?action=register&redirect_to=/wp-login.php?redirect_to=' . get_permalink());[/php]" title="Register">Register</a>

hope it helps...

0

You can use wp_registration_url() any where you want to add link to wordpress registration to add the redirection url use apply_filters()

<a href="<?php wp_registration_url( apply_filters( 'the_permalink', get_permalink( $post_id ) ) ); ?>" >click to register</a>

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