Add Lost Password Link

This code enables you to add a link to create a new password via email.

lost-password

Once you submit the form, you’ll be redirected back to the URL where you clicked the link. You will also recieve a email with link to reset your password.

The link works in exactly the same way as the link added below the login form.

You can also determine which URL the form redirects to after submission.

The following code snippets use wp lostpassword url

Themes Template File

If you’re using a theme like Twenty Sixteen, you can add trhe folloowing code to any template file like the header.php or footer.php.

<span class="lost-password">
<a href="<?php echo wp_lostpassword_url( get_permalink() ); ?>" title="Lost Password">Lost your password?</a>
</span><!-- .lost-password -->

Themes With Custom Hooks

Themes with custom hooks like Genesis, enable you to hook the link in from your functions file.

add_action( 'genesis_header_right', 'lost_password_link' );
function lost_password_link() {
printf( '<a class="button" href="%s" title="Lost Password">Lost Password</a>', wp_lostpassword_url( get_permalink() ) );
}

Related Code

Join 5000+ Followers

Get The Latest Free & Premium Tutorials Delivered The Second They’re Published.