27

I came here from google. But the answer didn't satisfy me. I was looking for a while and found a better solution. Add this to your functions.php: add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login function my_front_end_login_fail( $username ) { $referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come ...


22

I fixed it!!! Woohoo. Using this link - link to patch I edited the line it advises and it works fine.


20

After finding this question, and testing a few of the answers, the below is a "cleaned up" version of what I am using in a production environment. This version does not throw any notices / errors, and also allows for password resets to work: // Hook the appropriate WordPress action add_action('init', 'prevent_wp_login'); function prevent_wp_login() { /...


18

The current method I am using to deal with all of the issues outlined here works great even with blank username/password and doesn't rely on javascript (though the js could be good along with this). add_action( 'wp_login_failed', 'custom_login_failed' ); function custom_login_failed( $username ) { $referrer = wp_get_referer(); if ( $referrer &&...


12

just add the following code to your function.php. it will redirect back user from where the login form is submitted. add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login function my_front_end_login_fail( $username ) { $referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from? // if there's a valid ...


11

The login form is a simple html form sending username and password to wp-login.php. This is the simplest way to create a custom login form: <?php $redirect_to = ''; ?> <form name="loginform" id="loginform" action="<?php echo site_url( '/wp-login.php' ); ?>" method="post"> <p>Username: <input id="user_login" type="text" size="20" ...


10

Try this in your theme's functions.php add_action('init','custom_login'); function custom_login(){ global $pagenow; if( 'wp-login.php' == $pagenow && !is_user_logged_in()) { wp_redirect('http://yoursite.com/'); exit(); } }


10

The "correct" answer doesn't work here because the action 'password_reset' fires before the password is reset. I modified the first answer, before the update, to work. function wpse_lost_password_redirect() { // Check if have submitted $confirm = ( isset($_GET['action'] ) && $_GET['action'] == resetpass ); if( $confirm ) { ...


10

Had the same problem... clearing the cookies didn't do the trick. What did the trick was logging in via incognito mode first, and then I was able to login normally.


9

Here is a simple solution. Im hooking into login_headerurl. Maybe there is a better hook for this but it works, Put this in your functions.php: function wpse_lost_password_redirect() { // Check if have submitted $confirm = ( isset($_GET['checkemail'] ) ? $_GET['checkemail'] : '' ); if( $confirm ) { wp_redirect( home_url() ); ...


8

Create a template file within your child theme directory, let's say login.php. Put the login form inside this file: <form action="" method="post"> <div> User name: <input name="log" type="text" /> </div> <div> Password: <input name="pwd" type="password" /> </div> <div> <input type="...


6

To restrict direct access only for 'wp-login.php', without POST or GET request (useful for custom ajax login forms), I use the advanced function: function possibly_redirect(){ global $pagenow; if( 'wp-login.php' == $pagenow ) { if ( isset( $_POST['wp-submit'] ) || // in case of LOGIN ( isset($_GET['action']) && $_GET['action']=='...


6

This is what ended up working for me: Put your script into a .js file and then: add_action( 'login_enqueue_scripts', 'enqueue_my_script' ); function enqueue_my_script( $page ) { wp_enqueue_script( 'my-script', 'http://domain.com/path/myjs-file.js', null, null, true ); }


6

It finally hit me that javascript would be behind the interim login modal behavior, and that gave me a new direction in my search. I have disabled the new login popups by adding the following to my theme's functions.php file: // Disable login modals introduced in WordPress 3.6 remove_action( 'admin_enqueue_scripts', 'wp_auth_check_load' ); If anyone's ...


6

Don't modify core, use the actions and hooks system instead add_action( 'login_init', 'yourloginoverrides' ); function yourloginoverrides() { // do some check and call wp_redirect if its true or whatever you wanted to do }


5

Let's try this, Open up your wp-login.php file and add the following update_option calls, update_option('siteurl', 'http://your.domain.name/the/path' ); update_option('home', 'http://your.domain.name/the/path' ); beneath, require( dirname(__FILE__) . '/wp-load.php' ); so... it should look like, require( dirname(__FILE__) . '/wp-load.php' ); ...


5

Filter 'login_redirect'. Sample code, not tested: add_filter( 'wp_login', 'wpse_78150_login_redirect' ); function wpse_78150_login_redirect( $url ) { # uncomment the next line for debugging # var_dump( wp_get_current_user() ); exit; if ( ! current_user_can( 'custom_role' ) ) return $url; return admin_url(); }


5

I'm using this simple action, and it works like a charm. :) <?php /** Plugin Name: (#111223) User Login with Mail Address */     add_action( 'wp_authenticate', 'wpse111223_login_with_email_address' ); function wpse111223_login_with_email_address( $username ) { $user = get_user_by_email( $username ); if ( ! empty( $user->user_login ) ) $...


5

Using wp_deregister_style( 'login' ) to remove the login styles will still result in a 404'd request for the login CSS file. However, if you re-register the login style after deregistering it you can prevent the unwanted request. add_action( 'login_init', function() { wp_deregister_style( 'login' ); wp_register_style( 'login' ); } ); This will ...


5

There are many possible causes to this problem. Some have to do with your database. Try turning on WP_DEBUG and interpreting the error messages. In my own case (which is how I stumbled on your question here), the problems was writing a session token into usermeta. I went into PhpMyAdmin > wp_usermeta > and deleted the meta_value for session_token. (Detailed ...


5

There is no sane reason or method to do this "without a plugin", because the code necessary to accomplish the job should be contained within a plugin. Don't roll your own code, use a tried and tested plugin that is designed specifically for the job. That is the secure way.


5

Hi Please try to use this in your functions.php it will redirect user to login form when user try to access lost password page: add_action('init','possibly_redirect'); function possibly_redirect(){ if (isset( $_GET['action'] )){ if ( in_array( $_GET['action'], array('lostpassword', 'retrievepassword') ) ) { wp_redirect( '/wp-login.php' );...


5

@Kevin, here a couple options how to overwrite css for login page. Via login_enqueue_scripts If you use this hook, you need to create css file the same path with functions.php, say login-style.css, add your code inside, change your property background-image like this background-image: url(assets/images/logo.png); ( make sure your path correct ), and add ...


5

Wordpress uses those markers to put its rules between. I never have and never would put custom rules in there. Check out insert_with_markers() and save_mod_rewrite_rules() in wp-admin/includes/misc.php Most notably this comment block which answers your question: /** * Inserts an array of strings into a file (.htaccess ), placing it between * BEGIN and ...


5

To answer your specific question, "How can I modify the default reset (lost) password email text," the answer would be to use the retrieve_password_message filter. And ultimately that might be a way to solve your problem. But I think you need to dig a little deeper to figure out what's really going on. In your question you asked about modifying the "...


4

The login_init hook is the first one to be called in wp-login.php, so try hooking into it instead. function redirect_invalid_login() { global $error; if( $error ) { wp_redirect( get_bloginfo( 'url' ) . '/client-login/?message=6' ); die(); } } add_action( 'login_init', 'redirect_invalid_login' ); If that doesn't work, please ...


4

A solution for Szczepan Hołyszewski's point about empty fields in the accepted solution, the following jQuery will prevent going to the standard wp-login page: (add to login page template or footer.php) jQuery("#loginform-custom").submit(function(){ var isFormValid = true; jQuery("input").each(function() { if (jQuery.trim($(this)....


4

Add a GET var for the logout action and it works fine. add_action('init','custom_login'); function custom_login(){ global $pagenow; if( 'wp-login.php' == $pagenow && $_GET['action']!="logout") { wp_redirect('http://YOURSITE.com/'); exit(); } }


4

Here is a simple shortcode that gets the job done: add_shortcode('ajax_login','ajaxlogin_shortcode_handler'); function ajaxlogin_shortcode_handler($atts,$content=null){ if (is_user_logged_in()) return; $retval = '<p id="message" style="color:red"></p>' .wp_login_form(array('form_id' => 'ajaxloginform','echo' => ...


4

After wp-login.php figures out what error messages to display, the $errors object gets passed through the wp_login_errors filter: $errors = apply_filters( 'wp_login_errors', $errors, $redirect_to ); When that error message is added to the list of "errors", wp-login uses the code 'registered', which you can use to narrow down your search. So something like ...


Only top voted, non community-wiki answers of a minimum length are eligible