{"id":54471,"date":"2017-08-28T19:43:11","date_gmt":"2017-08-28T22:43:11","guid":{"rendered":"https:\/\/wiki.samuelchopard.ch\/?p=54471"},"modified":"2019-03-18T14:29:19","modified_gmt":"2019-03-18T13:29:19","slug":"redirect-user-if-wrong-password-was-entered","status":"publish","type":"post","link":"https:\/\/samuelchopard.ch\/wiki\/library\/redirect-user-if-wrong-password-was-entered\/","title":{"rendered":"Redirect user if wrong password was entered"},"content":{"rendered":"<p><!--more--><\/p>\n<p>Paste the following code in your theme&#8217;s <em>functions.php<\/em>:<\/p>\n<pre class=\"EnlighterJSRAW\">add_action( 'wp_login_failed', 'my_front_end_login_fail' );  \/\/ hook failed login\n\nfunction my_front_end_login_fail( $username ) {\n   $referrer = $_SERVER['HTTP_REFERER'];  \/\/ where did the post submission come from?\n   \/\/ if there's a valid referrer, and it's not the default log-in screen\n   if ( !empty($referrer) &amp;&amp; !strstr($referrer,'wp-login') &amp;&amp; !strstr($referrer,'wp-admin') ) {\n      wp_redirect( $referrer . 'echec' );  \/\/ let's append some information (login=echec) to the URL for the theme to use\n      exit;\n   }\n}<\/pre>\n<p><strong>Note:<\/strong> you can change &#8220;echec&#8221; for the text that suits you most. Once done, create a sub-page of your login page and change it&#8217;s permalink to &#8220;echec&#8221; or whatever else you modified it to.<\/p>\n<p>&nbsp;<\/p>\n<p>Source:\u00a0<a target=\"_blank\" href=\"https:\/\/wordpress.stackexchange.com\/questions\/15633\/how-can-i-redirect-user-after-entering-wrong-password\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/wordpress.stackexchange.com\/questions\/15633\/how-can-i-redirect-user-after-entering-wrong-password<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"Paste the following code in your theme's functions.php: add_action( 'wp_login_failed', 'my_front_end_login_fail' ); \/\/ hook failed login function my_front_end_login_fail( $username ) [...]","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3,9],"tags":[167,240,331],"class_list":["post-54471","post","type-post","status-publish","format-standard","hentry","category-php-tricks","category-wordpress","tag-login","tag-redirect","tag-wrong-password"],"_links":{"self":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54471","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/comments?post=54471"}],"version-history":[{"count":1,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54471\/revisions"}],"predecessor-version":[{"id":54860,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/posts\/54471\/revisions\/54860"}],"wp:attachment":[{"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/media?parent=54471"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/categories?post=54471"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/samuelchopard.ch\/wiki\/wp-json\/wp\/v2\/tags?post=54471"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}