How to change form action of wp-login page with a function

I'm manually creating my own Wordpress login form. The action parameter of all the forms points to wp-login.php. I want to change it for all of them to custom url (/login). Any idea how to that?

For example:

form name="lostpasswordform" id="lostpasswordform"
action="http://mywebsite.com/wp-login.php?action=lostpassword" method="post"

So I want to change the form action into mywebsite.com/login/?action=lostpassword Note, I need for both Login, Register and Lost Password.

Kind regards.

Topic wp-login-form functions url-rewriting actions forms Wordpress

Category Web


Follow standards instead of ugly solutions. Use WP filter (put inside functions.php):

add_filter( 'site_url', 'my_url_modifier', 10, 4 );

function my_url_modifier( $url, $path, $scheme, $blog_id)
{
    if($url=='http://mywebsite.com/wp-login.php?action=lostpassword')   
        return 'http://your_link..';
    else 
        return $url;
}

p.s. You should add other links there link example. Also, you can sanitise further parameters, like : if ($path=='wp-login.php')....

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.