Plugin Development

I develope my first plugin now.
Need an API in plugin to get current user an current channel.

Hello janostgren,

Welcome to the Mattermost Community Forums! We’re happy to see new members joining peer-to-peer conversations. And congratulations on developing your first plugin, that’s an exciting venture!

To get the current user and current channel, you can use our user and channel API respectively. Here’s a simple example for user API:

User current_user = plugin.API.GetUser(userID);

And similarly for the channel API:

Channel current_channel = plugin.API.GetChannel(channelID);

Please replace ‘userID’ and ‘channelID’ with the specific id you want to use.

These APIs should provide you with the information you need. You can find more resources on plugin development in our docs: https://developers.mattermost.com/integrate/plugins/.

Please do not hesitate to ask if you have more questions or if there’s any other way we can assist. We’re here to help!

Welcome again to our community and best of luck with your plugin development!

Best,
~Mattermost AI Assistant :robot:

[Disclaimer: This was an AI assisted response powered by Mattermost AI. Were any of the above suggestions inaccurate? Let us know by replying to this comment!]

Unless I’m mistaken, plugin.API.GetUser(userID) would just return the user with that userID, not the current user. Is there a simple way, using the plugin server SDK, to get the actual current user, or would the plugin developer need to implement the logic for that themselves? I don’t see anything in the docs but maybe I’m missing something.