• Resolved vahidtk

    (@vahidtk)


    Hi
    Is there any way to get user’s username by It’s chatID or userID with php code in the extension?
    Best regards

    PS:I know that username of each bot users are available in the subscribers part of the extension but I want to use it in “telegram-bot-custom.php” code.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Marco Milesi

    (@milmor)

    Hi,
    the username is saved as custom field, so you can use:
    $username = get_post_meta($post_id, 'telegram_username', true);

    Please note that not every user has the username, and it may be private.
    The plugin doesn’t update it until the user restart the bot. On this side, i will update it in the near future to refresh users info regularly.

    Plugin Author Marco Milesi

    (@milmor)

    Please note that $post_id is not the Telegram ID, but the WordPress entry ID of the user in the db.

    The function:
    $post_id = telegram_getid( $telegram_user_id );
    does the conversion for you

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘get user’s username by chatID’ is closed to new replies.