users.php
Helper functions that retrieve user data.
Tags
Table of Contents
- resolve_recipient() : WP_User|null
- Resolves a user from a string that may denote a username, login name, or email.
- get_move_recipient_suggestions() : array<string|int, mixed>
- Gets a list of user names that the specified user has previously sent internal transfers (moves) to.
- create_random_nonce() : string
- Generate a random string.
- get_legacy_api_key() : string
- Get a user's API key for the legacy JSON-API v3 (deprecated!).
- generate_random_bytes() : string
- Returns a hex-encoded string of API_KEY_BYTES random bytes.
- get_ids_for_users_with_cap() : array<string|int, int>
- Returns array of all users WITH the specified capability.
- get_ids_for_users_without_cap() : array<string|int, int>
- Returns array of all users WITHOUT the specified capability.
Functions
resolve_recipient()
Resolves a user from a string that may denote a username, login name, or email.
    
                    resolve_recipient(string $recipient) : WP_User|null
        Useful for sending internal transactions.
Parameters
- $recipient : string
- 
                    A string that may denote a user by their username, login name, or email. 
Return values
WP_User|null —The user found, or null if not found.
get_move_recipient_suggestions()
Gets a list of user names that the specified user has previously sent internal transfers (moves) to.
    
                    get_move_recipient_suggestions([int|null $user_id = null ]) : array<string|int, mixed>
    
        Parameters
- $user_id : int|null = null
- 
                    The sender's user id or null for current user. 
Return values
array<string|int, mixed> —A list of user names.
create_random_nonce()
Generate a random string.
    
                    create_random_nonce(int $length) : string
        Uses the cryptographically secure function random_int.
Parameters
- $length : int
- 
                    The desired length of the string. 
Tags
Return values
string —The generated string.
get_legacy_api_key()
Get a user's API key for the legacy JSON-API v3 (deprecated!).
    
                    get_legacy_api_key([int|null $user_id = null ]) : string
    
        Parameters
- $user_id : int|null = null
- 
                    The user whose API key to generate or retrieve. 
Tags
Return values
string —The user's API key, which is a HEX string of 32 bytes.
generate_random_bytes()
Returns a hex-encoded string of API_KEY_BYTES random bytes.
    
                    generate_random_bytes([int $bytes_count = 32 ]) : string
        Useful for generating API keys for the legacy JSON-API v3. The bytes are generated as securely as possible on the platform.
Parameters
- $bytes_count : int = 32
- 
                    How many random bytes to generate. 
Return values
string —Hex-encoded string of the generated random bytes.
get_ids_for_users_with_cap()
Returns array of all users WITH the specified capability.
    
                    get_ids_for_users_with_cap(string $capability) : array<string|int, int>
        Useful for retrieving users with has_wallets, etc.
Parameters
- $capability : string
- 
                    The capability to check for. 
Return values
array<string|int, int> —Array of user_ids.
get_ids_for_users_without_cap()
Returns array of all users WITHOUT the specified capability.
    
                    get_ids_for_users_without_cap(string $capability) : array<string|int, int>
        Useful for retrieving users with has_wallets, etc.
Parameters
- $capability : string
- 
                    The capability to check for. 
Return values
array<string|int, int> —Array of user_ids.