WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am using wp_signon function.

This is my ajax code.

                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){

                    if(html.trim() == 'ok'){    alert("sd");
                        jQuery('#login_error').html("You will be redirected soon...");
                        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...

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;
            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

Your Answer


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

Browse other questions tagged or ask your own question.