Fix for CRM-14105
authorWeb Access <rohan.katkar@webaccessglobal.com>
Tue, 17 Mar 2015 04:41:24 +0000 (10:11 +0530)
committerWeb Access <rohan.katkar@webaccessglobal.com>
Tue, 17 Mar 2015 04:41:24 +0000 (10:11 +0530)
CRM/Utils/System/WordPress.php

index 55171a158330ae8c5a07cffe73e1b57a8ba80295..6d5b8daf4e400f21148231f39c00ec1d1f835070 100644 (file)
@@ -351,6 +351,20 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     }
     require_once $cmsRootPath . DIRECTORY_SEPARATOR . 'wp-includes/pluggable.php';
     $uid = CRM_Utils_Array::value('uid', $name);
+    if (!$uid) {
+      $name = $name ? $name : trim(CRM_Utils_Array::value('name', $_REQUEST));
+      $pass = $pass ? $pass : trim(CRM_Utils_Array::value('pass', $_REQUEST));
+      if ($name) {
+        $uid = wp_authenticate($name, $pass);
+        if (!$uid) {
+          if ($throwError) {
+            echo '<br />Sorry, unrecognized username or password.';
+            exit();
+          }
+          return FALSE;
+        }
+      }
+    }
     if ($uid) {
       $account = wp_set_current_user($uid);
       if ($account && $account->data->ID) {