Leave a Reply

3 comments

  1. If you like to hand code the solution in your theme, instead of using a plugin, you should try this.

    $('#signin-form input[type="image"]').click(function(q){
        q.preventDefault();
        var inputData = $('#signin-form form').serialize();
        var loginUrl = $('#signin-form form').attr('action');
        var homeUrl = $('#signin-form input[name="redirect_to"]').attr('value');
        $.ajax({
            type: "POST",
            url:  loginUrl,
            data: inputData,
            success: function(msg){
                testData = $('#login-status',msg).html();
                if(testData == 'success'){
                    window.location = homeUrl;
                } else {
                    $('#signin-form .error').show(); // show error notification here
                }
            }
        });
    });
    

    First the function prevent the original login form submission (non ajax login) and replace it with an ajax request.

    If the provided username and password match, then we are supposed be redirected to a certain ‘logged-in page’. Else, we are redirected to the wp-admin/login.php

    On success, the function check whether we have the “#login-status” div with the content “success” on the ‘logged-in page’ or not. If we do, all we have to do is redirect current location. If we don’t, just show the error notification.

    Hope this help.

  2. Try using an AJAX login plugin. http://wordpress.org/extend/plugins/login-with-ajax/ If you don’t like a feature, all of the code is at your fingertips. That’s the beauty of open source, you can take what someone has built and make it even better and give it back to the community. My position is that if it’s already out there, why reinvent the wheel? Use what is given to propel your project further, faster (giving original authors credit where credit is due obviously).