Opened 2 years ago

Closed 7 months ago

#16411 closed enhancement (invalid)

Custom Login and Registration URLs

Reported by: danielpataki Owned by:
Priority: normal Milestone:
Component: General Version:
Severity: normal Keywords:
Cc: trac@…

Description

For bigger websites it would be beneficial to allow custom registrations by being able to change the login and registration urls. You can change the login url in a haphazard way now like this, but this is not very good.

function bsb_login_url($redirect_to) {
	$redirect_to = str_replace(get_bloginfo("url").'/wp-login.php', '', $redirect_to);
	$link = get_bloginfo("url")."/login/".$redirect_to;
	return $link;
}   
add_filter( 'login_url', 'bsb_login_url' );

Looking at wp-login.php, the registration link is output like this:

<a href="<?php echo site_url('wp-login.php?action=register', 'login') ?>"><?php _e('Register') ?></a>

If, by using a filter, hook, or even a definition in the config file, you could change the url output here that would be nice.

Change History (12)

Just want to add quickly, that this can also be accomplished in another bad way like this:

add_action("init", "bsb_register_redirect") ;

function bsb_register_redirect() {
	
	if(get_current_url(true) == get_bloginfo('url')."/wp-login.php?action=register");
	header("Location: http://bitesizebio.com/register/");
} 
Version 0, edited 2 years ago by danielpataki (next)

comment:2 follow-up: ↓ 3   SergeyBiryukov2 years ago

There are plugins for that. Theme My Login is one for example.

Last edited 2 years ago by SergeyBiryukov (previous) (diff)

comment:3 in reply to: ↑ 2   markmcwilliams2 years ago

Replying to SergeyBiryukov:

There are plugins for that. Theme My Login is one for example.

I think he's on about having site.com/login/ and site.com/register/ instead of the site.com/wp-login.php and site.com/wp-login.php?action=register we currently have, although this will more than likely be plugin material, as it can be achieved through either functions.php or a plugin!

comment:4 follow-up: ↓ 5   SergeyBiryukov2 years ago

Theme My Login can do that. Sorry for the wrong link, fixed.

comment:5 in reply to: ↑ 4   markmcwilliams2 years ago

Replying to SergeyBiryukov:

Theme My Login can do that. Sorry for the wrong link, fixed.

Oh, I never noticed I was looking at the wrong plugin!

It's not the fact that it can not be done which is the problem, I just think that this should be something the core could support. For larger websites, having a more elaborate registration, lost password and login process is a must, and it would be easier to achieve with built in support.

  • Cc trac@… added

There exists a wp_login_form function to address this (at least, part of it).

Ozh has a plugin that does /login instead of /wp-login.php. I don't think it would be too hard for it to also handle /register if someone asked/sent him a patch.

  • Summary changed from Custom Login and Registration URLs to http://scrapeboxmurah.blogspot.com/2012/05/iklan-internet-murah-efektif.html

spam

Last edited 10 months ago by dd32 (previous) (diff)
  • Summary changed from http://scrapeboxmurah.blogspot.com/2012/05/iklan-internet-murah-efektif.html to Custom Login and Registration URLs
  • Milestone Awaiting Review deleted
  • Resolution set to invalid
  • Status changed from new to closed

There's nothing haphazard about using the 'login_url' filter; it's the standard way of extending WordPress.

What's missing is a matching wp_register_url() and is_login_url() functions, which are addressed in #19898

Note: See TracTickets for help on using tickets.