Title: Call to undefined function getallheaders()
Last modified: October 31, 2019

---

# Call to undefined function getallheaders()

 *  Resolved [cudak](https://wordpress.org/support/users/cudak/)
 * (@cudak)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/call-to-undefined-function-getallheaders-2/)
 * Hi there,
    im using the newest verion (1.2.0) of this plugin with wordpress 5.2.4.
   When I try to call “wp-json/wp/v2/users/me” I get the following error log: `Fatal
   error: Uncaught Error: Call to undefined function getallheaders() in /home/forge/
   pt.alphactor.de/public/wp-content/plugins/wp-rest-api-authentication/admin/partials/
   flow/class-mo-api-authentication-jwt-auth.php:5 Stack trace: #0 /home/forge/pt.
   alphactor.de/public/wp-content/plugins/wp-rest-api-authentication/admin/partials/
   flow/mo-token-api-flow.php(125): Mo_API_Authentication_JWT_Auth::mo_api_auth_is_valid_request()#
   1 /home/forge/pt.alphactor.de/public/wp-content/plugins/wp-rest-api-authentication/
   admin/partials/flow/mo-token-api-flow.php(105): mo_api_auth_is_valid_request()#
   2 /home/forge/pt.alphactor.de/public/wp-content/plugins/wp-rest-api-authentication/
   admin/class-miniorange-api-authentication-admin.php(166): mo_api_auth_restrict_rest_api_for_invalid_users()#
   3 /home/forge/pt.alphactor.de/public/wp-includes/class-wp-hook.php(286): Miniorange_API_Authentication_Admin-
   >mo_api_auth_initialize_api_flow(Object(WP_REST_Server)) #4 /home/forge/pt.alphactor.
   de/public/wp-includes/class-wp-hook.php(310): WP_Hook->apply in /home/forge/pt.
   alphactor.de/public/wp-content/plugins/wp-rest-api-authentication/admin/partials/
   flow/class-mo-api-authentication-jwt-auth.php on line 5`

Viewing 1 replies (of 1 total)

 *  Plugin Author [miniOrange](https://wordpress.org/support/users/cyberlord92/)
 * (@cyberlord92)
 * [6 years, 7 months ago](https://wordpress.org/support/topic/call-to-undefined-function-getallheaders-2/#post-12103487)
 * Hi,
 * getallheaders() is an apache specific function. However, there are some versions
   of PHP (especially Zend) that do not contain this function.
 * We will publish a release soon to handle this case for PHP versions which has
   this issue.
 * Alternatively, you can add the below code in your functions.php
 *     ```
       if (!function_exists('getallheaders')) {
                   function getallheaders() {
                       $headers = [];
                       foreach ($_SERVER as $name => $value) {
                           if (substr($name, 0, 5) == 'HTTP_') {
                               $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
                           }
                       }
                       return $headers;
                   }
               }
       ```
   

Viewing 1 replies (of 1 total)

The topic ‘Call to undefined function getallheaders()’ is closed to new replies.

 * ![](https://ps.w.org/wp-rest-api-authentication/assets/icon-128x128.png?rev=2084327)
 * [JWT Authentication for WP REST APIs](https://wordpress.org/plugins/wp-rest-api-authentication/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-rest-api-authentication/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-rest-api-authentication/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-rest-api-authentication/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-rest-api-authentication/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-rest-api-authentication/reviews/)

 * 1 reply
 * 2 participants
 * Last reply from: [miniOrange](https://wordpress.org/support/users/cyberlord92/)
 * Last activity: [6 years, 7 months ago](https://wordpress.org/support/topic/call-to-undefined-function-getallheaders-2/#post-12103487)
 * Status: resolved