Log into WordPress using stored username and password

Any ideas how I can approach logging into a WordPress site using a username and password stored within an iPhone app? I am looking for a pointer in the right direction from someone who’s done this before, because I didn’t find many details on the web.

Related posts

Leave a Reply

1 comment

  1. You could set your WP site to use wp_signon() ( http://codex.wordpress.org/Function_Reference/wp_signon ) to receive the credentials and sign you in right away.

    Could be something like:

    <?php
    
       //First check useragent/nonce to make sure it's coming from your phone/app
    
       //Now get credentials and log in
       $creds = array();
       $creds['user_login'] = $_POST['usr'];
       $creds['user_password'] = $_POST['pwd'];
       $creds['remember'] = true;
       $user = wp_signon( $creds, false );
       if ( is_wp_error($user) ){
          echo $user->get_error_message();
       } else {
         //do your stuff
       } 
    ?>
    

    Not super sophisticated, but could be a start =)

    Hope that helps!