From 78e6c5a4ee81d333715291b7247acc0dd4c02af3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 7 Mar 2026 11:44:46 -0800 Subject: [PATCH] Fix fatal error: WP_REST_Server::get_request() does not exist Store authenticated user ID on the auth object instance instead of trying to retrieve it from the REST server request. This was the root cause of all mobile API 500 errors. Co-Authored-By: Claude Opus 4.6 --- includes/class-twp-mobile-auth.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/class-twp-mobile-auth.php b/includes/class-twp-mobile-auth.php index 7a235c8..805f19d 100644 --- a/includes/class-twp-mobile-auth.php +++ b/includes/class-twp-mobile-auth.php @@ -9,6 +9,7 @@ class TWP_Mobile_Auth { private $secret_key; private $token_expiry = 86400; // 24 hours in seconds private $refresh_expiry = 2592000; // 30 days in seconds + private $current_user_id = null; /** * Constructor @@ -330,7 +331,7 @@ class TWP_Mobile_Auth { } // Store user ID for later use - $request->set_param('_twp_user_id', $payload->user_id); + $this->current_user_id = $payload->user_id; return true; } @@ -339,8 +340,7 @@ class TWP_Mobile_Auth { * Get current user ID from token */ public function get_current_user_id() { - $request = rest_get_server()->get_request(); - return $request->get_param('_twp_user_id'); + return $this->current_user_id; } /**