These are chat archives for WP-API/node-wpapi

7th
Feb 2017
zahid-avyatech
@zahid-avyatech
Feb 07 2017 08:18
WP WC customer login api: you dont need to make any oauth,you have to create a folder in your wordpress project and call the following code and run from your browser and paas username and paasword: require ("../wp-load.php");
if($_REQUEST['pass'] != "" && $_REQUEST['email'] != "")
{
             $ar = wp_authenticate_email_password("",$_REQUEST['email'] ,$_REQUEST['pass'] );
             $class_name = get_class ($ar);
             if ( $class_name == "WP_User" ) 
             { 
                    $user_id = $ar->data->ID;

                  $arr = array(
                   "id" => $user_id,
                   "email"  => $ar->data->user_email,
                   "name"   => $ar->data->display_name,
                  );
                  $ar = array ("status" => 200,"message"=>"Login Successful", "data" => $arr);
                  echo json_encode($ar);
                  exit();
             } 
             else 
             {
                  $ar = array ("status" => 400, "message" => "Invalid email or password");
                  echo json_encode($ar);
                  exit();
             }
    } 
    else 
    {
             $ar = array ("status" => 400, "message" => "Require Field Missing.[email and pass]");
             echo json_encode($ar);
             exit();
    }