开发者

Log into Wordpress using stored username and password

开发者 https://www.devze.com 2023-03-10 20:31 出处:网络
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 be

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 bef开发者_运维知识库ore, because I didn't find many details on the web.


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!

0

精彩评论

暂无评论...
验证码 换一张
取 消