Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I am using wp_signon function.

This is my ajax code.

jQuery.ajax({
                type: 'POST',
                url : '<?php echo bloginfo('template_url');?>/ajax/loggedin.php',
                cache : false,
                async : false,  
                data : {
                    'uname' : login_id,
                    'upass' : login_pass
                },
                success : function(html){

                jQuery("#LoadingImage").hide();
                    if(html.trim() == 'ok'){    alert("sd");
                        jQuery('#login_error').html("You will be redirected soon...");
                        window.location="http://www.iguanapaint.com/";
                        //window.location(site_url+"/dashboard/");
                    }else{
                        jQuery('#login_error').html('<div class="error">Invalid Username or Password</div><p class="mrgn"></p><div class="clear"></div>');
                        return false;
                    }

                }
            });

and this is PHP code...

include_once('../../../../wp-config.php');
if($_POST['uname']!="" && $_POST['upass']!=""){ 
    $uname = sanitize_user($_POST["uname"]);
    $upass = strip_tags($_POST["upass"]);   
    $creds = array();
    $creds['user_login'] = $uname;
    $creds['user_password'] = $upass;
    $creds['remember'] = true;
    $user = wp_signon( $creds, true );  

        if ( is_wp_error($user) ){
             $login_error = $user->get_error_message();                    
            echo    $login_error;
         }else{         
            echo "ok";          
         }

}

When I am signing in then it is not redirecting me to iguanapaint.com instead shows error invalid username and password while now if reload the page then it sets the cookie and it is already loggedin.

And also when I see in firebug it shows two ajax request.

1 - to loggedin.php and shows that 302 moved temporarily 2 - to iguanapaint.com

share|improve this question
    
Instead of alert("sd");, have you tried alert(html.trim()); to see what is actually being returned? –  s_ha_dum Jun 29 '13 at 15:15
    
@s_ha_dum In return total html is coming of home page (iguanapaint.com) –  Bhuvnesh Gupta Jul 1 '13 at 4:23
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.