Skip to content

mastodon_api_canonical_user_id

Alex Kirk edited this page Feb 8, 2025 · 4 revisions

Map a user id to a canonical user id.

This allows to ensure that the user id stays the same no matter of the relationship to this user. For example, if external user information is fetched about a user and we later follow that user, the user id should stay the same.

Auto-generated Example

add_filter(
    'mastodon_api_canonical_user_id',
    function ( int $user_id ) {
        // Your code here
        return $user_id;
    }
);

Parameters

  • int $user_id The user ID.

Returns

int The potentially modified user ID.

Files

apply_filters( 'mastodon_api_canonical_user_id', $user_id )
apply_filters( 'mastodon_api_canonical_user_id', $remote_user_id->name )
apply_filters( 'mastodon_api_canonical_user_id', $user_id )

Hooks

Clone this wiki locally