get_api_session_code_user()
Description
Read an eligible credential owner's current details from the primary database without caching.Account approval, expiry, group membership and API download-limit restrictions must still hold.
Parameters
| Column | Type | Default | Description |
|---|---|---|---|
| $user: | int | ps_query "SELECT u.ref | |
| u.username | |||
| u.email | |||
| u.fullname | |||
| $redirect_uri; | |||
| < | 0 | 0" | |
| ['i' | |||
| $user] | |||
| '' | |||
| -1 | |||
| true | |||
| code | single-use | ||
| false | or | ||
| destination | |||
| or | challenge | ||
| $system | string | ||
| $redirect_uri | string | ||
| $code_challenge | string | ||
| string | #[\SensitiveParameter] | get_api_session_destination$system | |
| $user | int | User reference. |
Return
| array|false | Current user details, or false if session/API access is unavailable. |
Location
include/user_api_session_functions.php lines 65 to 82
Definition
function get_api_session_code_user(int $user): array|false
{
$rows = ps_query(
"SELECT u.ref, u.username, u.email, u.fullname, u.session
FROM user u INNER JOIN usergroup g ON u.usergroup = g.ref
WHERE u.ref = ? AND u.approved = 1
AND (u.account_expires IS NULL OR u.account_expires = '0000-00-00 00:00:00'
OR u.account_expires > NOW())
AND u.session IS NOT NULL AND u.session <> ''
AND COALESCE(g.download_limit, 0) <= 0",
['i', $user],
'',
-1,
true,
0
);
return $rows[0] ?? false;
}
This article was last updated 29th October 2026 18:35 Europe/London time based on the source file dated 29th October 2026 14:30 Europe/London time.