Try this:
add_action( 'lost_password', 'wpse316932_redirect_wrong_email' );
function wpse316932_redirect_wrong_email() {
global $errors;
if ( $error = $errors->get_error_code() ) {
wp_safe_redirect( 'lost-password/?error=" . $error );
} else {
wp_safe_redirect( "lost-password/' );
}
}
This is utilizing the lost_password
action hook that fires right before the lost password form.
You were experiencing this because WP will only redirect you to the url you specified in redirect_to
input field when there is no errors. If it finds errors in processing the form (which is the obvious case here), it simply continues with rendering the form on the wp-login.php
page. By using this action you can hook into this procedure right before that.
Related Posts:
- how to redirect to a custom password retrieval page
- Custom protected password page with ACF
- How do I remove the eye icon that shows visibility on login screen and reset password screen
- How to implement a custom password field that redirects to another page upon correct password?
- Deep customization of wp-login.php
- Lost password empty field error redirect to custom login
- Custom Log In Screen – Disable password recovery [duplicate]
- Password Protection issue
- Custom password set/reset link in same URL format as default does’t work
- How to Password Protect whole site except for some subdirectories
- Accountless password generation
- New WP_Customize API – how does it work under the hood?
- Data sanitization: Best Practices with code examples
- Prevent WordPress from automatically installing a new theme each year
- Can we use one WordPress installation for multiple databases, domains and content directories
- How to include own css on wordpress tinymce editor?
- how to override woocommerce specific loop or archive-product.php [closed]
- How to Add Customizer Setting in Child Theme
- When adding a custom REST endpoint, where do you put the endpoint function, and where do you put the function registration call?
- global menus made from master site’s custom menus wpmu network
- Capability to edit own posts and not others
- Make page template that is just an “include” of another?
- Is there a way to create invisible pages?
- What’s the easiest way to periodically (automatically) read static Markdown content into a WP page?
- How can I add data to a custom column in the Users section of the wordpress backend?
- Volume mounts when setting up WordPress with docker [closed]
- Is it possible to replace PHP with NodeJS?
- Change separators in HTML tags
- Problem with using wp-load.php outside of WordPress
- How to remove padding and margin between divi rows? [closed]
- Renaming wp_content problem
- Include user defined styles without including wp-load
- Cannot figure out how to center div in WordPress theme [closed]
- Preserve custom URL parameter after saving post
- Warning: Creating default object… when altering Customize panels
- Adding custom field in all widgets, but at the top of the form, in admin area
- WordPress customizer Preview not loading
- Always logged in even if remember me is unchecked?
- Adding posts to custom menu [closed]
- How to add an extra variable to login and authenticate it?
- Color swatches on category page? [closed]
- Theme Customization through admin panel. (Appearance-Customize)
- Best practice – pages – ACF or inline coding
- Diffrent User registration form for doctor and patient
- User can not login
- wpdb custom tables without plugin
- 404 (category, pages, archives) when using custom rewrite rules
- Keep Title and Description always
- Changer numbers of columns in woocommerce shop
- How to put a site offline, including images?
- Use custom header as WordPress header
- WordPress : using AJAX to get posts & Sidebar Content to an external application
- str_replace inside specific css files [closed]
- How to edit alternate inactive themes in “Appearance -> Customise” screen?
- Prevent Multisite from creating sample page, sample post and sample comments
- WordPress archive index page
- WordPress Code Snippet to count total posts by author
- Custom Same Page Search
- Inline-Table under TwentyTwelve not working
- Allow a subscriber to be an author and view only his post
- How to make WordPress search page use a relative path
- Woocommerce custom archive page custom content and shortcode
- We are facing this error in header unable to understand the issue
- When is the wp-settings-[time] cookie generated?
- What is my error trying to create a new table in the database?
- Need to add custom text field to Woocommerce under add to cart button
- Hide entry-header for a specific category
- How to add a template – so that i can choose a different menu for some pages
- Allow WP users to sort search result on a videos site
- wp.blocks.registerBlockType not showing what I want on the frontend
- Multiple loops on same category with different design
- Add a menu item to admin dashboard which isn’t a link? [duplicate]
- How Can I add show_post_count in get_archives_link?
- How to add the option to choose between sizes for featured image within post editor?
- Customize WP website specific column with CSS
- Help needed creating a custom Hamburger menu in header
- admin aoolbar add_node() and pulling in my post slug
- Structure of post types for TV Shows and episodes
- Custom Form Input not saving to Database
- Adding images to anchors in the list created and fetched with wp_nav_menu
- In wordpress customizer api adding div wrap to control
- How to create 2 preview button in a post?
- Change the default WordPress image on the dashboard login to a custom image [duplicate]
- Secondary loop doesn’t work
- Custom user fields validation on registration
- Pre_Get_Posts order DESC not registering
- Adding pages to the Admin panel
- Share user access between two wordpress sites
- What capability is required to view posts, scheduled in the future, by someone else?
- Custom Query Arguments
- Adding page Title in a custom coded page
- Reached end of document without finding – using mod_pagespeed
- Gallery Pagination by Row
- use another theme for just one page
- Custom Post want button to add image and save in Postmeta
- Save And Display Mp3 Audio files on WooCommerce product page with Dokan
- Advice how to connect custom database with WordPress, change data in WordPress and finaly use this data
- Sort Search Results in Order of/by Character @ count (9) of post(s) title. (Ocean-WP theme)
- Is it possible assign a secondary existing role to already existing one?
- Set custom banner image size with wp_customize