Jump to content

How can I programmatically subscribe a user to a topic?


Omri Amos

Recommended Posts

Posted

Hi,

I'm using REST API in order to allow users to post topics/posts to the forum from my website.
The topics/posts are created successfully, they are assigned to the users, and everything works great - beside one issue: after sending the topic/post, the user does not get subscribed to the topic (even if the user's default settings is to automatically subscribe to topics they reply in).

I wish that the REST API would automatically subscribe the user to the topic after posting the reply / creating a topic.
If it's not possible with the REST API (which seems to be the case) then I would love to hear any ideas about a workaround.

I don't mind even running a SQL query directly (so after the REST API call, I will perform the query to subscribe the user_id to topic_id), if that will be the only solution, but I was unable to easily find out where in the database this is actually saved...

Thanks

Posted

Look inside applications/core/modules/front/system/notifications.php and/or system/Content/Item.php, search for core_follow inside the files. 

Weirdly enough they don't have a method for this, so they actually use raw database queries in both those places. 

Posted

The code looks awfully complicated with stuff like "application", "followArea", etc'... but it actually pointed me to the "core_follow" table (how did I miss that? :rofl: ), which looks much easier to understand.

Thanks again :)

 

Posted

UPDATE: I was able to manually subscribe the user, but then I noticed another issue - when adding a post using the REST API, it does not SEND A NOTIFICATION to subscribed users.....

So now I also need to find a way to "send" the notification about this post to the subscribed users.... help? :)

UPDATE / EDIT:
My bad it seems to be working fine 
 

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...