Move content of returning response into CRM_Utils_System and have user_system based...
[civicrm-core.git] / CRM / Utils / System / WordPress.php
index a1a9c64fd3442faa8604b7f8f3f29e993cf585eb..84cba04f8847189ca92858346c53ea17eed006dc 100644 (file)
@@ -401,7 +401,8 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
    * Determine the native ID of the CMS user.
    *
    * @param string $username
-   * @return int|NULL
+   *
+   * @return int|null
    */
   public function getUfId($username) {
     $userdata = get_user_by('login', $username);
@@ -862,4 +863,19 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
     ];
   }
 
+  /**
+   * Set the HTTP Status Code for a request
+   * @param string $statusCode
+   */
+  public function setStatusCode($statusCode) {
+    status_header($statusCode);
+    if (function_exists('http_response_code')) {
+      // PHP 5.4+
+      http_response_code($statusCode);
+    }
+    else {
+      header('X-PHP-Response-Code: ' . $statusCode, TRUE, $statusCode);
+    }
+  }
+
 }