# Determining if the authenticated API user has liked the post in the getTopic API response

**URL:** <https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [April 2, 2020, 10:57am UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566 "2020-04-02T10:57:18Z")\
**Posts on this page:** 6\
**Page:** 1

## AI-generated summary

In a discussion about determining if an authenticated API user has liked a post within the `getTopic` response, [benbowler](/t/-/146566/1) reported an issue while developing a WordPress commenting plugin. Although the `actions_summary` array correctly displayed the total like count, the `can_act` property remained `true` regardless of whether the specific user had already liked the post. [Arkshine](/t/-/146566/2) clarified that the correct indicator is the `acted: true` flag, which should appear if the API user has performed the action. After investigating this suggestion, [benbowler](/t/-/146566/4) confirmed the solution: the issue was caused by the plugin not correctly requesting data based on the passed user context. They noted they would update their fork of the `discourse-api-php` library to assist others facing similar challenges.

<div class="post-metadata">

**Author:** ![benbowler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benbowler/32/174749_2.png) [@benbowler](https://meta.discourse.org/u/benbowler)\
**Post date:** [April 2, 2020, 10:57am UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/1 "2020-04-02T10:57:18Z")

</div>

I’ve been working on a Wordpress commenting plugin for the last week and have had great success connecting to, creating posts and updating data via the Discourse API and my fork of the discourse-php-API plugin - [Work through the createPost request to get it working by benbowler · Pull Request #14 · communiteq/discourse-api-php · GitHub](https://github.com/communiteq/discourse-api-php/pull/14)

Looking at the /posts response I can see the actions summary response for each post and get the total count of likes.

```
actions_summary: Array(6)
0: {id: 2, count: 1, can_act: true}
1: {id: 3, can_act: true}
2: {id: 4, can_act: true}
3: {id: 8, can_act: true}
4: {id: 6, can_act: true}
5: {id: 7, can_act: true}
length: 6
__proto__ : Array(0)

```

But can\_act is true regardless of whether the user has liked the post or not. How do you show the correctly?

---

<div class="post-metadata">

**Author:** ![Arkshine](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/arkshine/32/298682_2.png) [@Arkshine](https://meta.discourse.org/u/Arkshine)\
**Post date:** [April 2, 2020, 11:31am UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/2 "2020-04-02T11:31:14Z")

</div>

If the user you’re using with the API (`Api-Username`) has liked a post, you should see `acted: true`

---

<div class="post-metadata">

**Author:** ![benbowler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benbowler/32/174749_2.png) [@benbowler](https://meta.discourse.org/u/benbowler)\
**Post date:** [April 2, 2020, 11:34am UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/3 "2020-04-02T11:34:04Z")

</div>

> [@Arkshine](#):
>
> acted: true

Hmm, let me take a look.

---

<div class="post-metadata">

**Author:** ![benbowler](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/benbowler/32/174749_2.png) [@benbowler](https://meta.discourse.org/u/benbowler)\
**Post date:** [April 2, 2020, 11:41am UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/4 "2020-04-02T11:41:29Z")

</div>

I’ve got it. The plugin wasn’t requesting based on the passed user. I’ll update the library to help anyone in future.

---

<div class="post-metadata">

**Author:** ![system](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/system/32/443519_2.png) [@system](https://meta.discourse.org/u/system)\
**Post date:** [April 19, 2024, 4:37pm UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/5 "2024-04-19T16:37:19Z")

</div>

Automatically bumped on April 19, 2024, 4:37pm UTC



---

<div class="post-metadata">

**Author:** ![JammyDodger](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jammydodger/32/254611_2.png) [@JammyDodger](https://meta.discourse.org/u/JammyDodger)\
**Post date:** [April 19, 2024, 8:39pm UTC](https://meta.discourse.org/t/determining-if-the-authenticated-api-user-has-liked-the-post-in-the-gettopic-api-response/146566/6 "2024-04-19T20:39:42Z")

</div>

Closed on April 19, 2024, 8:39pm UTC


