Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to registration page in Wordpress

Tags:

wordpress

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.

like image 309
Captain Comic Avatar asked Mar 04 '11 08:03

Captain Comic


People also ask

How do I add a registration link in WordPress?

Simply head over to the Settings » General page in your WordPress admin area. Scroll down to the 'Membership' section and check the box next to 'Anyone can register' option.

How do I link login page and registration page?

All you have to do is, go to User Registration -> Settings. Now, click on the Login Options tab. Now, insert the slug of your registration page in the Registration URL box. And below that, you will find a Registration URL label option.


3 Answers

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());  ?> 
like image 192
johnhunter Avatar answered Oct 01 '22 13:10

johnhunter


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;
}
like image 38
Jake Avatar answered Oct 01 '22 14:10

Jake


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?)

like image 41
Mark Avatar answered Oct 01 '22 13:10

Mark